32

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.

2
  • 3
    cat dr-operators-config.json | python -m json.tool Commented Oct 27, 2017 at 16:02
  • 3
    python -m json.tool... good to know it exists. Commented Jul 4, 2018 at 14:39

1 Answer 1

19

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.

Sign up to request clarification or add additional context in comments.

Comments

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.