thanks for reading I am creating a json file as a result of an API that I am using. My issue is that the outcome gets has \h and '' in it and a .json file does not process the \n but keeps them, so the file becomes faulty.
This is my code, it is python:
json_arr = []
for text in gtm_Q6_df['ANSWER']:response = natural_language_understanding.analyze(text=text,language = 'en',features=Features(categories=CategoriesOptions(limit=3),)).get_result()#print("Input text: ",text)#print(json.dumps(response, indent=2))json_data = (json.dumps(response, indent=2))json_arr.append (json_data)with open('data.json','w') as outline: #with open('data.json','w') as outline:json.dump(json_arr,outline)print("break")
print(json_arr)
['{\n "usage": {\n "text_units": 1,\n "text_characters": 113,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.734718,\n "label": "/business and industrial/advertising and marketing/marketing"\n },\n {\n "score": 0.675452,\n "label": "/business and industrial/business operations/management/business process"\n },\n {\n "score": 0.620496,\n "label": "/business and industrial/advertising and marketing/brand management"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 215,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.913644,\n "label": "/technology and computing/operating systems"\n },\n {\n "score": 0.855434,\n "label": "/technology and computing/hardware/computer"\n },\n {\n "score": 0.842841,\n "label": "/technology and computing/hardware/computer components/chips and processors"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 14,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.885687,\n "label": "/automotive and vehicles/cars/hybrid"\n },\n {\n "score": 0.821966,\n "label": "/automotive and vehicles/electric vehicles"\n },\n {\n "score": 0.77387,\n "label": "/shopping/retail"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 86,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.967686,\n "label": "/education/homework and study tips"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 80,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.822388,\n "label": "/automotive and vehicles/cars/sedan"\n },\n {\n "score": 0.754857,\n "label": "/automotive and vehicles/cars/hybrid"\n },\n {\n "score": 0.68194,\n "label": "/automotive and vehicles/cars/car culture"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 13,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.921873,\n "label": "/real estate/architects"\n },\n {\n "score": 0.790383,\n "label": "/business and industrial/construction"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 52,\n "features": 1\n },\n "language": "en",\n "categories": [\n
{\n "score": 0.939684,\n "label": "/technology and computing/computer reviews"\n },\n {\n "score": 0.931032,\n "label": "/technology and computing/tech news"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 14,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.979729,\n "label": "/education/homework and study tips"\n
},\n {\n "score": 0.850809,\n "label": "/real estate/architects"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 28,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.999484,\n "label": "/education/teaching and classroom resources"\n }\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 113,\n "features":
1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.734718,\n "label": "/business and industrial/advertising and marketing/marketing"\n },\n {\n "score": 0.675452,\n "label": "/business and industrial/business operations/management/business process"\n },\n {\n "score": 0.620496,\n "label": "/business and industrial/advertising and marketing/brand management"\n
}\n ]\n}', '{\n "usage": {\n "text_units": 1,\n "text_characters": 215,\n "features": 1\n },\n "language": "en",\n "categories": [\n {\n "score": 0.913644,\n "label": "/technology and computing/operating systems"\n },\n {\n "score": 0.855434,\n "label": "/technology and computing/hardware/computer"\n },\n {\n "score": 0.842841,\n "label": "/technology and computing/hardware/computer components/chips and processors"\n }\n ]\n}']