我有这个JSON有效的JSONArray
[
{
"RestaurantName": "OhrisHome",
"Locality": "Near Office"
},
{
"RestaurantName": "SwagtahtHome",
"Locality": "Near Home"
}
]
我需要用一些名字来识别这个数组
所以我试图为这个JSON数组添加一个Key,如图所示
{
"Type" : "Home"
[
{
"RestaurantName": "OhrisHome",
"Locality": "Near Office"
},
{
"RestaurantName": "SwagtahtHome",
"Locality": "Near Home"
}
]
}
答案 0 :(得分:1)
在对象中,它们的键将是数组的名称,值将是数组本身。只需更改" ArrayName"更适合的事情。
{
"Type" : "Home",
"ArrayName" :
[
{
"RestaurantName": "OhrisHome",
"Locality": "Near Office"
},
{
"RestaurantName": "SwagtahtHome",
"Locality": "Near Home"
}
]
}