0

I am trying to parse a JSON file which is of the following format

[  
   {  
      "name":"name1",
      "age":"age1"
   },
   {  
      "name":"name2",
      "age":"age2"
   },
   {  
      "name":"name3",
      "age":"age3"
   }
]

When I use the JSON parser in python I am getting the following error:

> ValueError: No JSON object could be decoded

Here is my code :

import json

with open('sample.json') as data_file:    
    data = json.load(data_file)

print(data)
4
  • 5
    Cannot reproduce... Commented Nov 7, 2017 at 16:31
  • As far as I can see, your JSON file is valid, and your code seems correct. Perhaps there's some additional, unmentioned detail? Commented Nov 7, 2017 at 16:33
  • Check for invisible characters like BOM in the file. Commented Nov 7, 2017 at 17:06
  • Check out this link... There might be encoding problem stackoverflow.com/questions/26808814/… Commented Nov 7, 2017 at 17:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.