我正在为体育和子体育创建JSON,如下所示:
{
"sportName": "Men's Basketball",
"path": "mbasket",
"sportID": 7,
"parentSportName": "Basketball"
}, {
"sportName": "Women's BasketBall",
"path": "wcc",
"sportID": 8,
"parentSportName": "Basketball"
}, {
"sportName": "Women's Cross Country",
"path": "wbasket",
"sportID": 9,
"parentSportName": "Cross Country"
}, {
"sportName": "Men's Cross Country",
"path": "mcc",
"sportID": 10,
"parentSportName": "Cross Country"
}
现在我想在parentSportName 下嵌套sportName,即 越野将包含男子越野和女子越野。我需要在JSON中做些什么改变?
PS:我正在创建一个嵌套列表。
答案 0 :(得分:0)
添加包含嵌套运动数组的顶级运动数组。此示例传递json lint验证器。
var parentSports=
[
{
"parentSportName": "Basketball",
"sports":[
{
"sportName": "Men's Basketball",
"path": "mbasket",
"sportID": 7
}, {
"sportName": "Women's BasketBall",
"path": "wcc",
"sportID": 8
}]
},{
"parentSportName": "Cross Country",
"sports": [
{
"sportName": "Women's Cross Country",
"path": "wbasket",
"sportID": 9
}, {
"sportName": "Men's Cross Country",
"path": "mcc",
"sportID": 10
}]
}
];