NoobProg
NoobProg

Reputation: 91

JSON file to dataframe conversion-ValueError: Unexpected character found when decoding array value (2)

I have a huge json file having the format of the form:

[{"faceId": "2cb5a26a-1acc-4eb2-8c39-8e05e604f057", "faceRectangle": {"top": 
54, "left": 125, "width": 78, "height": 78}, "faceAttributes": {"smile": 
0.584, "headPose": {"pitch": 0.0, "roll": -2.4, "yaw": 1.4}, "gender": 
"male", "age": 34.4, "facialHair": {"moustache": 0.5, "beard": 0.6, 
"sideburns": 0.3}, "glasses": "NoGlasses", "emotion": {"anger": 0.0, 
"contempt": 0.003, "disgust": 0.0, "fear": 0.0, "happiness": 0.584, 
"neutral": 0.413, "sadness": 0.0, "surprise": 0.0}, "blur": {"blurLevel": 
"high", "value": 1.0}, "exposure": {"exposureLevel": "goodExposure", 
"value": 0.61}, "noise": {"noiseLevel": "low", "value": 0.0}, "makeup": 
{"eyeMakeup": false, "lipMakeup": false}, "accessories": [{"type": 
"headwear", "confidence": 1.0}], "occlusion": {"foreheadOccluded": true, 
"eyeOccluded": false, "mouthOccluded": false}, "hair": {"bald": 0.0, 
"invisible": true, "hairColor": []}}}]

I am trying to convert this to a dataframe by using the following code:

import pandas as pd
ent_json_file = 'ent.json'
reading_json =   pd.read_json(ent_json_file,convert_dates=True,lines=True)

I am getting the following error:

ValueError: Unexpected character found when decoding array value (2)

Any help is greatly appreciated! Thanks!

Upvotes: 4

Views: 13437

Answers (1)

SummerEla
SummerEla

Reputation: 1952

Your error seems to be coming from an invalid JSON format.

I've found that online JSON lints are a quick and easy way to figure out what's going on with a JSON file:

https://jsonlint.com/

Upvotes: 6

Related Questions