I get the below error when i try to read a JSON file, not sure what needs to be corrected:
C:\Users\prabhjot2600\PycharmProjects\PythonPractise\venv\Scripts\python.exe C:/Users/prabhjot2600/Desktop/Prabh/alien_invasion/test.py
Traceback (most recent call last):
File "C:/Users/prabhjot2600/Desktop/Prabh/alien_invasion/test.py", line 26, in <module>
data = json.loads(people_string)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 11 column 21 (char 192)
My code is simply reading a JSON file and printing its data. I have checked my JSON data also which looks correct and also formatted it to see if there were any errors left but still cant read the JSON
import json
people_string = '''
{
"people": [
{
"name": "Prabhjot Singh",
"phone": "9999596310",
"emails": [
"[email protected]",
"[email protected]"
],
"hasLicence": True
},
{
"name": "Sunny Rana",
"phone": "9999988888",
"emails": null,
"hasLicence": False
}
]
}
'''
data = json.loads(people_string)
print(data)
trueandfalseinstead ofTrueandFalse.