falukky
falukky

Reputation: 1139

Python json.loads lead to Extra data Exception

This is how my file look like:

enter image description here

My code

import json

with open(r'c:\sample.json') as json_file:
    data = json.load(json_file)

And I got this error:

Extra data: line 18 column 2 (char 294)

What does it mean ? what extra data ?

Upvotes: 1

Views: 484

Answers (2)

Yuval.R
Yuval.R

Reputation: 1306

The structure should look like this:

[
  {
    "bat":"0",
    ...
  },
  {
    "bat":"0",
    ...
  },
]

Upvotes: 1

Hadrian
Hadrian

Reputation: 927

a json file can only be one data structure, if you want to put multiple dicts in it, then you can put them in a list

[
    {...},
    {...},
    ...
]

Upvotes: 2

Related Questions