I have a list of objects in this format as below. I wanted to save it in a json file format.
{'result': [{'topleft': {'y': 103, 'x': 187}, 'confidence': 0.833129, 'bottomright': {'y': 375, 'x': 271}, 'label': 'person'}]}
I was able to print the objects as above. But, when I try to save it in JSON format. I encounter error "raise TypeError(repr(o) + " is not JSON serializable")"
Here's part of my code:
def writeToJSONFile(data):
filePathNameWExt = '/media/test/abc.json'
with open(filePathNameWExt, 'w') as fp:
json.dump(data, fp)
result = tfnet.return_predict(img)
data['result']=result
print (data)
writeToJSONFile(data)