我正在编写以下JSON文件代码供我用它将其发布到我的网站
{
fleetSubscriberId:
{
subscriberId: "The subscriberId used during login",
name: "Subscriber name",
groupId: "Subscriber group ID",
companyCode: "Subscriber company code"
},
fleetPolicySummaries:
[
{
policyNumber: "1234", companyCode: "456"
}
],
{
"companyName": "Natural Resources Canada",
"locations":
[
{
"streetAddress": "580 Booth St 17th Fl Room a6",
"city": "Ottawa",
"stateOrProvince": "Ontario",
"country": "Canada"
}
]
}
}
显示以下错误可以帮助我解决这个问题
Error: Parse error on line 1:
{ fleetSubscriberId:
-----^
Expecting 'STRING', '}', got 'undefined'
答案 0 :(得分:0)
字段名称是文字。
您也应该引用字段名称(例如"fleetSubscriberId":
)以使其成为有效的JSON。
答案 1 :(得分:0)
检查一下。我格式化了你的JSON。注意我添加了一个新的“其他”作为字段名称。
{
"fleetSubscriberId": {
"subscriberId": "The subscriberId used during login",
"name": "Subscriber name",
"groupId": "Subscriber group ID",
"companyCode": "Subscriber company code"
},
"fleetPolicySummaries": [
{
"policyNumber": "1234",
"companyCode": "456"
}
],
"other": {
"companyName": "Natural Resources Canada",
"locations": [
{
"streetAddress": "580 Booth St 17th Fl Room a6",
"city": "Ottawa",
"stateOrProvince": "Ontario",
"country": "Canada"
}
]
}
}
答案 2 :(得分:-1)
你可以在这里检查你的json是否有效。 http://pro.jsonlint.com/ 你的json无效。