I am trying to extract values from JSON without the parent keys.
Here is the JSON structure I have:
[
{
"companies": [{
"id": 1,
"name": "Prueba",
"company_number": "23423423A",
"latitude": 241241.12,
"longitude": 213213.12,
"country": "ES"
},
{
"id": 2,
"name": "Prueba2",
"company_number": "23423423A",
"latitude": 241241.12,
"longitude": 213213.12,
"country": "US"
},
{
"id": 3,
"name": "Prueba3",
"company_number": "23423423AB",
"latitude": 241241.19,
"longitude": 213213.20,
"country": "US"
}
]
},
{
"centers":[
{
"id": 1,
"name": "Prueba4",
"center_number": "23423423A",
"latitude": 241241.12,
"longitude": 213213.12,
"country": "ES"
},
{
"id": 2,
"name": "Prueba5",
"center_number": "23423423A",
"latitude": 241241.12,
"longitude": 213213.12,
"country": "US"
}
]
}
]
In my Ionic project using Angular, I've written the following code:
<ion-list>
<ion-item *ngFor="let p of profiles; let i=index">
<p>{{i}}</p> <!-- this works fine-->
<ion-list>
<ion-item *ngFor="let s of p[i]; let i2=index">
<p>{{p[i][i2][name]</p>
</ion-item>
</ion-list>
</ion-item>
The desired output is:
- Prueba
- Prueba2
- Prueba3
- Prueba4
- Prueba5
Is it possible to achieve this directly in front-end or should I process it beforehand?
Thank you in advance