[英]json format error when creating object with arrays as values
I want to create a json object (to be later used as a mongodb
document, but that's of no particular importance for the moment).我想创建一个 json 对象(稍后用作
mongodb
文档,但目前这不是特别重要)。
I want the document to have in its top level the week identifier as key.我希望文档在其顶层将周标识符作为键。 Its value will be an array.
它的值将是一个数组。
So far so good.到现在为止还挺好。
I want then each of this array's key-value pairs to have:我希望这个数组的每个键值对都具有:
Here is my sample:这是我的示例:
{
"Week_18_25_12":[
"Monday": [
{
"vegan":"food1"
},
{
"regular":"food1"
},
{
"vegeterian":"food3"
},
{
"veggie":"food4"
},
{
"salad":"mysalad"
}
],
"Tuesday": [
{
"vegan":"food1"
},
{
"regular":"food1"
},
{
"vegeterian":"food3"
},
{
"veggie":"food4"
},
{
"salad":"mysalad"
}
]
]
}
I cannot understand why I get a format error right on the semicolon following the name of the day.我不明白为什么我在日期名称后面的分号上出现格式错误。 (when I replace it with a comma, it is OK)
(当我用逗号替换它时,就可以了)
Isn't this supposed to be a key-value pair with the day name as key and the array with food types as value?这不应该是一个以日期名称为键,以食物类型为值的数组的键值对吗?
The format should be like格式应该是这样的
{
"Week_18_25_12":{
// and the other key-pairs inside
}
}
instead of "Week_18_25_12":[ ]而不是“Week_18_25_12”:[ ]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.