Reading JSON file with Python 3
Reading JSON file with Python 3
Try this
import json
with open(filename.txt, r) as f:
array = json.load(f)
print (array)
Based on reading over the documentation again, it appears you need to either change the third line to
json_data = json.loads(text)
or remove the line
text = json_file.read()
since read()
causes the files index to reach the end of the file. (I suppose, alternatively, you can reset the index of the file).
Reading JSON file with Python 3
For python3, only the below worked for me – none of the above.
import json
with open(/emp.json, r) as f:
data=f.read()
print(data)