Oct-12-2021, 06:22 AM
Hi
I'm working with dictionaries where values are (numpy) arrays, and I'm trying to figure out how to export these dictionaries in an JSON format, and how to read it afterward.
I'm not familiar with JSON specifications and that's why I'm facing some issues : does somebody can advice me on docs to read 'and fto fill my lacks) involving dictionnaries and arrays?
Thanks
Paul
In the following code, only an array is tested
I'm working with dictionaries where values are (numpy) arrays, and I'm trying to figure out how to export these dictionaries in an JSON format, and how to read it afterward.
I'm not familiar with JSON specifications and that's why I'm facing some issues : does somebody can advice me on docs to read 'and fto fill my lacks) involving dictionnaries and arrays?
Thanks
Paul
In the following code, only an array is tested
## to write Json file b = np.ndarray.tolist(MyArray) json.dump(b, codecs.open(PATH + '/export.json', 'w', encoding='utf-8'), separators=(',', ':'), sort_keys=True, indent=4) ## to read it afterward with open(PATH + '/export.json', "r") as JsonArray: json.load(JsonArray)
Error:TypeError: the JSON object must be str, bytes or bytearray, not TextIOWrapper