close

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

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Error Occurs?

Today I get the following error json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) in python.

How To Solve json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Error ?

  1. How To Solve json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Error ?

    To Solve json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Error My solution to this would be to use the string.replace() to convert these items to a string:

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

    To Solve json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Error My solution to this would be to use the string.replace() to convert these items to a string:

Solution 1

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}
    ]
}

Solution 2

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 json

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

string = string.replace("False", '"False"')

dict_list = json.loads(string)

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read