kushagra
kushagra

Reputation: 151

How can I convert "google.cloud.documentai_v1.types.document" object to json

I am using Google Cloud Document AI's Invoice Parser. API response is google.cloud.documentai_v1.types.Document object. I tried to write below approaches for converting it to JSON but nothing works:

Upvotes: 4

Views: 3320

Answers (1)

bernatj
bernatj

Reputation: 147

You should be able to get the JSON with the to_json method you mentioned, but you have to pass the document you want to get as a JSON file, such as

google.cloud.documentai_v1.Document.to_json(my_document)

which will output the JSON file.

Upvotes: 7

Related Questions