删除导致语法无效的EOF



我们将如何摆脱文件结束错误?根据ecma,括号似乎是有效的,不清楚遗漏了什么。使用jsonlint,发现如下:

*Error: Parse error on line 16:
...States"      }]  }]}{    "id": 1,    "name":
------------------^
Expecting 'EOF', '}', ',', ']', got '{'*

我们如何修复这个错误?

{
//   "summersalads": [
//     {
//       "id":0,
//       "name": "Tabouli",
//       "web":"The Hungry Greek.com",
//       "description":"Crisp Romaine lettuce, with chopped cucumbers, olives, topped with Feta cheese and hummus",
//       "addresses":[
//         {
//           "addressid":"0",
//           "number":"808",
//           "line1":"N.",
//           "line2":"Franklin St",
//           "zipcode":"33602",
//           "country":"United States"
//         }
//         ]
//       }
//     ]
//   }
//     {
//   "id":1,
//   "name":"Papaya Salad",
//   "restaurant":"Ahi Asian Bistro",
//   "web":"www.ahiasianbistro.com",
//   "description":"Shrimp, green papaya, garlic, tomato, carrrot, green beans, peanut, lime juice dressing",
//   "addresses":[
//     {
//       "addressid":"1",
//       "number":"14841",
//       "line1":"N.",
//       "line2":"Dale Mabry",
//       "zipcode":"33618",
//       "country":"United States"
//     }
//   ]
// }

你的json是无效的。错误消息显示您需要一个逗号物体之间,移动]和添加}到json的末尾。你的json应该是

{
"summersalads": [
{
"id": 0,
"name": "Tabouli",
"web": "The Hungry Greek.com",
"description": "Crisp Romaine lettuce, with chopped cucumbers, olives, topped with Feta cheese and hummus",
"addresses": [
{
"addressid": "0",
"number": "808",
"line1": "N.",
"line2": "Franklin St",
"zipcode": "33602",
"country": "United States"
}
]
},          
{
"id": 1,
"name": "Papaya Salad",
"restaurant": "Ahi Asian Bistro",
"web": "www.ahiasianbistro.com",
"description": "Shrimp, green papaya, garlic, tomato, carrrot, green beans, peanut, lime juice dressing",
"addresses": [
{
"addressid": "1",
"number": "14841",
"line1": "N.",
"line2": "Dale Mabry",
"zipcode": "33618",
"country": "United States"
}
]
}
]
}

最新更新