When I read JSON file it gives me following error:
json.decoder.JSONDecodeError: Extra data: line 16043 column 2 (char 370886)
This error seems to be valid as json.load
does not decode multiple json objects and my JSON contains 2 or more objects.
{ "log": [
{
"code": "info",
"message": {"text": "[info] Activation of plug-in abcd rule processor (xule) successful, version Check version using Tools->Xule->Version on the GUI or --xule-version on the command line. - xule "},
"refs": [{"href": "xule"}],
"level": "info"
}
,
{
"code": "xyz.F1.all.7",
"level": "error",
"message": {
"text": "[xyz.F1.all.7] The value for ForResale with a value of 63 has a unit of utr:MWh. This concept allows units of utr:MWh.\n\nElement : xyz:ForResale\nPeriod : 2016-01-01 to 2016-12-31\nUnit : utr:MWh\n\nRule Id:xyz.F1.all.7 - TestUtilitiesInc-428-2016Q4F1.abcd 4114",
"severity": "error",
"cid": "63096080",
"filing_url": "C:\\Users\\TEST\\Desktop\\TestUtilitiesInc-428-2016Q4F1.abcd"
},
"refs": [{"href": "xule"}]
}]
}
{ "log": [
{
"code": "info",
"message": {"text": "[info] Activation of plug-in abcd rule processor (xule) successful, version Check version using Tools->Xule->Version on the GUI or --xule-version on the command line. - xule "},
"refs": [{"href": "xule"}],
"level": "info"
}
,
{
"code": "xyz.F1.all.7",
"level": "error",
"message": {
"text": "[xyz.F1.all.7] The value for ForResale with a value of 63 has a unit of utr:MWh. This concept allows units of utr:MWh.\n\nElement : xyz:ForResale\nPeriod : 2016-01-01 to 2016-12-31\nUnit : utr:MWh\n\nRule Id:xyz.F1.all.7 - TestUtilitiesInc-428-2016Q4F1.abcd 4114",
"severity": "error",
"cid": "63096080",
"filing_url": "C:\\Users\\TEST\\Desktop\\TestUtilitiesInc-428-2016Q4F1.abcd"
},
"refs": [{"href": "xule"}]
}]}
I came across this article for resolution: Python json.loads shows ValueError: Extra data
which says I need to add my log dictionaries in json.dumps()
prior to json.loads()
. But, I am unable to get it done. Please can anyone help me.
This is my python code:
with open('C:/Users/Desktop/SampleTestFiles/logfile.json', encoding="utf-8") as json_file:
data = json.load(json_file)