Stack Exchange
Error Parsing json data python
I have a json file which I am parsing in the following way:
data = open('DataFile.json', 'r')
data = json.load(data)

It works perfectly when I use this code in simple python script but when I run this in a method which calls other functions as well it throws 
 File "C:/Users/****/PycharmProjects/SDP/WebServices.py", line 143, in methodForParsing
    data = json.load(data)
  File "C:\Users\****\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\json\__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\****\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\json\__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "C:\Users\****\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\****\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I have checked on json formatter and other online websites, my json format is correct. I dont't know why it is not working in a method.

print(data.read()) just before parsing or print(data.read()[:100]) if it's too much so that we can see what it looks like.

It's unlikely that we'll be able to help you solve this problem unless you show us the contents of the file that you are trying to decode...

Have you double-mega-confirmed that you are reading the correct json file? Printed it, for example?

@anonymous loads is for strings, load is correct for files.

How are you calling it exactly? I suspect you have read from the file-handle which you are passing to json.load already and it is returning an empty string.
