如果检索此JSON,如何生成此JSON

时间:2019-07-12 07:00:12

标签: javascript json multidimensional-array

我正在使用vueJS和axios从API检索JSON对象,但是,我需要创建特定格式的JSON

我尝试创建对象和数组,但似乎无法遍历对象数组中的对象

这是我的API返回的JSON

[object Array]

{"Prizes" : 
    {
     "Title": "Major Prize",
     "Country": "Canada", 
     "Leaders": [{
            "LeaderName" : "Canada Leader A",
            "LeaderEmail" : "CanadaLeader.A@Canada.com",
            "LeaderID" : "CL1"
          },
          {
            "LeaderName" : "Canada Leader B",
            "LeaderEmail" : "CanadaLeader.B@Canada.com",
            "LeaderID" : "CL2"
          }],
     "SubLeaders": [{
        "SubLeaderName": "Sub Canada Leader A",
        "SubLeaderEmail": "SubCanadaLeader.A@Canada.com",
        "SubLeaderID" : "CSL1"
      }]
    },
    {
     "Title": "Major Prize",
     "Country": "USA", 
     "Leaders": [{
        "LeaderName" : "USA Leader A",
        "LeaderEmail" : "USALeader.A@Canada.com",
        "LeaderID" : "UL1"
      }],
     "SubLeaders": [{
        "SubLeaderName": "Sub USA Leader A",
        "SubLeaderEmail": "SubUSALeader.A@Canada.com,
        "SubLeaderID" : "USL1"
      }]
     },
     {
    "Title": "Minor Prize",
     "Country": "Japan", 
     "Leaders": [{
        "LeaderName" : "Japan Leader A",
        "LeaderEmail" : "JapanLeader.A@Canada.com",
        "LeaderID" : "JL1"
      }],
     "SubLeaders": [{
        "SubLeaderName": "Sub Japan Leader A",
        "SubLeaderEmail": "SubJapanLeader.A@Canada.com,
        "SubLeaderID" : "JSL1"
      }]
    }
}

我希望按标题将其分组,并且所有孩子都应按国家(包括领导者和子领导者)进行分组

0 个答案:

没有答案