我正在将JSON文件转换为.csv,而转换时却出现了“预期的EOF,得到','”之类的错误
{
"id": 22970,
"type": "message",
"date": "2018-11-24T21:08:21",
"edited": "1970-01-01T03:00:00",
"from": "lox",
"from_id": 731504644,
"text": "no"
},
{
"id": 22971,
"type": "message",
"date": "2018-11-24T21:08:32",
"edited": "1970-01-01T03:00:00",
"from": "Gox",
"from_id": 417024817,
"text": "ok"
}
它表明必须删除第一个块之后的逗号,但是当我删除它时,下一个{会显示红色。我该如何格式化才能正常转换?
答案 0 :(得分:1)
您的JSON不正确,带或不带逗号。
我相信您正在尝试使用JSON对象数组。如果是这样,语法应如下所示
[ // Array of objects
{ // Object 1
"id": 22970,
"type": "message",
"date": "2018-11-24T21:08:21",
"edited": "1970-01-01T03:00:00",
"from": "lox",
"from_id": 731504644,
"text": "no"
}, // Comma separating array items
{ // Object 2
"id": 22971,
"type": "message",
"date": "2018-11-24T21:08:32",
"edited": "1970-01-01T03:00:00",
"from": "Gox",
"from_id": 417024817,
"text": "ok"
}
]
我建议以后使用任何在线JSON parser来检查语法错误。