4
I have an API that a chunk of it returns the following array, and for each index has an object slas
that brings all carriers:
[
{
"itemIndex": 0,
"selectedSla": "Expressa",
"selectedDeliveryChannel": "delivery",
"slas": [
{
"name": "Expressa",
"shippingEstimate": "2bd",
"price": 1390
},
{
"name": "SEDEX",
"shippingEstimate": "2bd",
"price": 1990
},
{
"name": "Retira em SÃO PAULO (1936769)",
"shippingEstimate": "1bd",
"price": 0
}
]
},
{
"itemIndex": 1,
"selectedSla": "Expressa",
"selectedDeliveryChannel": "delivery",
"slas": [
{
"name": "Expressa",
"shippingEstimate": "2bd",
"price": 1390
},
{
"name": "SEDEX",
"shippingEstimate": "2bd",
"price": 1990
},
{
"name": "Retira em SÃO PAULO (1936769)",
"shippingEstimate": "1bd",
"price": 0
}
]
}
]
I wanted to add up the total value of each carrier.
Example:
0: EXPRESSA 13,90 + 1: EXPRESSA 13,90
0: SEDEX 19,90 + 1: SEDEX 13,90
Could post the exact return of the api, as posted is not valid.
– LeAndrade
@Leandrade json is very extensive so I summarized it in the section that refers.
– Steve Angello
The way it is there is no way to form a correct answer, because there is no way to know the structure of json.
– LeAndrade
@Leandrade Sorry, now json is validated.
– Steve Angello
If the goal is to group by
slas
there are already questions about this– Isac
@Isac I found nothing similar, could inform which questions are?!
– Steve Angello
As an example you can look at this or this
– Isac