复杂的数据结构语法

时间:2016-02-27 13:16:22

标签: arrays json object data-structures push

我有一个clubs数组,如下所示:

    [
        {
            "name": "Arsenal",
            "codeName": "arsenal",
            "nickName": "Gunners",
            "dateFounded": "1886",
            "stadium": "Emirates Stadium",
            "manager": "Arsène Wenger",
            "squad": []        
        }, 
        {
            "name": "Aston Villa",
            "codeName": "aston-villa",
            "nickName": "Villans",
            "dateFounded": "1874",
            "stadium": "Villa Park",
            "manager": "Rémi Garde",
            "squad": []
        }
     // and so on...
    ]

...我希望用相关数据填充每个空squad数组。对于AFC伯恩茅斯,我想.push() bournemouth数组(见下文)squad数组的clubs属性:

[               
        {"firstName": "Artur",
            "lastName": "Boruc",
            "nationality": "pl",
            "position": "gk",
            "shirtNumber": "1",
            "age": "36"},

        {"firstName": "Adam",
            "lastName": "Federici",
            "nationality": "au",
            "position": "gk",
            "shirtNumber": "23",
            "age": "31"},
 // and so on...
] 

首先,这可能吗?其次,这是解决这个问题的可行方法,还是有更有效/更好的方法来做到这一点?

在我开始编译所有数据之前,我想确定一下。

任何帮助/建议都会受到高度赞赏。

0 个答案:

没有答案