I have the following json data in a file that I am trying to read in python but I am getting this error. What am I doing wrong?
[
{
"name": "Alex C",
"age": 2,
"city": "Houston"
},
{
"name": "John G",
"age": 40,
"city": "Washington"
},
{
"name": "Bala T",
"age": 22,
"city": "Bangalore"
}
]
Here is my code:
JFile = "JData.json"
F = open(JFile, "w")
try:
proc = subprocess.Popen([MyCMD], shell=True, encoding='utf-8', stdout=F)
except Exception as ex:
print("ERROR: CMD Failed....", ex)
F.close()
try:
with open(JFile, 'r', encoding='utf-8') as J:
JData = json.loads(J.read())
except json.decoder.JSONDecodeError as e:
print("invalid json", e)
When I try to run this I get this error:
invalid json Expecting value: line 1 column 1 (char 0)