我正在使用一个发送 JSON 响应的 API,如下所示:
[
- {
"id": 46843639,
"nickname": "JSON",
"registration_date": "2004-03-07T23:16:20.000-04:00",
"country_id": "BR",
"user_type": "normal",
"logo": null,
"points": 91,
"site_id": "JSN",
"permalink": "http://xxxxxx",
"seller_reputation": - {
"level_id": "2_orange",
"power_seller_status": null,
"transactions": - {
"period": "historic",
"total": 14,
"completed": 8,
"canceled": 6,
"ratings": - {
"positive": 1,
"negative": 0,
"neutral": 0,
},
},
},
"status": - {
"site_status": "active",
},
},
]
我在任何规范文档中都找不到减号“-”。这是 JSON 标准吗?
最佳答案
不,不是。服务器正在向您发送损坏的 JSON。
-
唯一有效的情况是当它位于字符串中、紧接在数字之前或紧跟在 e
或 E< 后面时
为 float 。
除此之外,逗号应该分隔名称/值对和数组元素,而不是跟在它们后面。每个对象/数组中最后一个条目后面的逗号也是无效的。
关于JSON 包含负 ("-") char : is this valid/standard?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10148423/