4

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!

2
  • The sample you provided is working fine on my system. The error is due to a json which is not proper in that file. Commented Apr 24, 2018 at 5:33
  • Thanks for your answer.I just realized that there was a comma missing between each of the responses and hence resulting in an error!Appreciate your help! Commented Apr 24, 2018 at 5:44

1 Answer 1

6

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.