import json response = textract.analyze_document(Document={'Bytes': imageBytes},FeatureTypes=["FORMS"]) json_invoice_test = json.dumps(response) with open("json_invoice_test1.json", 'w') as outfile: outfile.write(json_invoice_test) with open("json_invoice_test2.json", 'w') as outfile: json.dump(response, outfile)