I need to deserialize json-serialized Azure Form Recognizer results into python FormRecognizer objects (from azure-ai-formrecognizer==3.1.0b1 package), and I do not see any sort of api to perform this deserialization. Any help would be appreciated.
Depending on how you are parsing, if you just need to access RecognizedForm
attributes and don't need a true RecognizedForm
object (in other words, just the shape of a RecognizedForm
object), this might work for you:
import json
from types import SimpleNamespace
recognized_form = json.loads(recognized_form_json, object_hook=lambda fields: SimpleNamespace(**fields))
Otherwise, we can manually deserialize it back to a RecognizedForm
. See this gist for an example (not fully tested).