python - JSON 文件到数据帧转换-ValueError : Unexpected character found when decoding array value (2)

标签 python json python-3.x pandas

我有一个巨大的 json 文件,其格式如下:

[{"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": []}}}]

我尝试使用以下代码将其转换为数据框:

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

我收到以下错误:

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

非常感谢任何帮助! 谢谢!

最佳答案

您的错误似乎来自无效的 JSON 格式。

我发现在线 JSON lint 是一种快速、简单的方法来了解 JSON 文件的情况:

https://jsonlint.com/

关于python - JSON 文件到数据帧转换-ValueError : Unexpected character found when decoding array value (2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49993514/

相关文章:

c++ - 在 qt 中解析嵌套 json 的意外结果(数组不存在)

python - Discord.py Async 的问题 - 欢迎留言

python - 如何访问 Python 3 中重新引发的异常?

python - 如何实现 "where"(numpy.where(...) )?

python - fatal error C1083 : Cannot open include file: 'Carbon/Carbon.h' : No such file or directory

java - 为不同结构的每个 JSON 响应创建 POJO?

python - 任意大小的网格内的最佳 4 字布局

jquery - 使用 jquery 将数据保存到本地 json 文件

python - 如何在 Python 3 的 assertRegex 中表达多行正则表达式?

json - 无法获取 Amazon S3 文件的内容并使用 python 和 boto3 编辑该文件