Within my JSON object, there is a list of countries each with multiple regions stored in an array. My goal is to extract and combine all the regions into one single list. However, when I attempt to map the data, it does not consolidate all the regions as expected. What might be causing this issue?
Below is the code snippet used to retrieve the JSON data specifically focusing on extracting the regions:
this.service.getData().subscribe((data: any) => {
this.list = data.map((c:any) => c.Regions);
});
The structure of the JSON object looks like this:
{
"Country": "Antarctica",
"Regions": [
"Adélie Land",
"Argentine Antarctica",
"Australian Antarctic Territory",
"British Antarctic Territory",
"Chilean Antarctic Territory",
"Peter I Island",
"Queen Maud Land",
"Ross Dependency"
]
},
{
"Country": "Antigua And Barbuda",
"Regions": []
},
{
"Country": "Argentina",
"Regions": [
"Buenos Aires",
"Cordoba",
"Buenos Aires City",
"Catamarca",
"Chaco",
"Chubut",
"San Luis",
"Santa Cruz",
"Santa Fe",
"Santiago del Estero",
"Tierra del Fuego",
"Tucuman",
"Mendoza",
"Misiones",
"Neuquen",
"Rio Negro",
"Salta",
"San Juan",
"Corrientes",
"Entre Rios",
"Formosa",
"Jujuy",
"La Pampa",
"La Rioja"
]
},