deserialize RecognizedForm object from json (Azure Form Recognizer Python SDK)

D. Reagan

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.

Krista

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).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related