30

I have a data.json file that I'm validating through the command line using python's json.tool, but it keeps giving me back an error message:

$ python -m json.tool < data.json
No JSON object could be decoded

Here are the contents of data.json:

$ cat data.json
{ "fields": 
    [
        [ "first_name", null, {} ],
        [ "last_name", null, {} ],
        [ "addr1", null, {} ],
        [ "addr2", null, {} ],
        [ "city", null, {} ],
    ]
}

I don't have a problem with single quotes, nor is the file empty (obviously), so I'm not sure what's causing the problem here.

Community
  • 1
  • 1
3cheesewheel
  • 9,133
  • 9
  • 39
  • 59

1 Answers1

18

It was because of the trailing comma after the last nested list [ "city", null, {} ]. I accidentally left it in and JSON doesn't allow them.

Community
  • 1
  • 1
3cheesewheel
  • 9,133
  • 9
  • 39
  • 59