I want to parse a json file and print the data in console. I have a json file as input.json in which the content is :
{ "name":"John", "age":30, "city":"New York"}
Now I'm running a python script in the same directory where the input file is stored but getting the error. The python script looks like this :
import json
# Opening JSON file
f = open('input.json','r')
data = json.load(f)
print(data)
Error is:
File "C:\Users\madhav\Desktop\New folder (2)\instaclient\req.py", line 9, in <module>
data = json.load(f)
File "C:\Users\madhav\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
File "C:\Users\madhav\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\madhav\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\madhav\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)