Two JSON files are available: one containing team names and codes, and the other with match details and scores. The goal is to create another JSON file that aggregates total matches won-lost and total goals.
The JSON files are located at:
- JSON 1
- JSON 2
I attempted to use the rest operator...
Example JSON Data - Json1:
{
"name": "English Premier League 2011/12",
"clubs": [
{
"key": "chelsea",
"name": "Chelsea",
"code": "CHE"
},
{
"key": "arsenal",
"name": "Arsenal",
"code": "ARS"
},
{
"key": "tottenham",
"name": "Tottenham Hotspur",
"code": "TOT"
}
]
}
Example JSON Data - Json2:
{
"name": "English Premier League 2011/12",
"rounds": [
{
"name": "Round 1",
"matches": [
{
"date": "2012-01-11",
"team1": {
"key": "tottenham",
"name": "Tottenham Hotspur",
"code": "TOT"
},
"team2": {
"key": "everton",
"name": "Everton",
"code": "EVE"
},
"score1": 2,
"score2": 0
},
...
]
}
]
}
Expected Result in JSON Format:
"clubs": [
{
"key": "chelsea",
"name": "Chelsea",
"code": "CHE",
"total_matches":38,
"won":"21",
"lost":"15",
"ties":"2",
"total-goals":"33",
"scored-against":"28"
},
{
"key": "arsenal",
"name": "Arsenal",
"code": "ARS",
"total_matches":38,
"won":"21",
"lost":"15",
"ties":"2",
"total-goals":"33",
"scored-against":"28"
}]