json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) [duplicate] json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) [duplicate] json json

json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) [duplicate]


You have two records in your json file, and json.loads() is not able to decode more than one. You need to do it record by record.

See Python json.loads shows ValueError: Extra data

OR you need to reformat your json to contain an array:

{    "foo" : [       {"name": "XYZ", "address": "54.7168,94.0215", "country_of_residence": "PQR", "countries": "LMN;PQRST", "date": "28-AUG-2008", "type": null},       {"name": "OLMS", "address": null, "country_of_residence": null, "countries": "Not identified;No", "date": "23-FEB-2017", "type": null}    ]}

would be acceptable again. But there cannot be several top level objects.


I was parsing JSON from a REST API call and got this error. It turns out the API had become "fussier" (eg about order of parameters etc) and so was returning malformed results. Check that you are getting what you expect :)


This error can also show up if there are parts in your string that json.loads() does not recognize. An in this example string, an error will be raised at character 27 (char 27).

string = """[{"Item1": "One", "Item2": False}, {"Item3": "Three"}]"""

My solution to this would be to use the string.replace() to convert these items to a string:

import jsonstring = """[{"Item1": "One", "Item2": False}, {"Item3": "Three"}]"""string = string.replace("False", '"False"')dict_list = json.loads(string)