08-17-2023 04:03 AM
Hi there, need some help transforming the array
I have a structure that's coming as below
[
{
"statusLine": {
"protoVersion": "HTTP/1.1",
"statusCode": 200,
"reasonPhrase": "OK"
},
"entity": {
"links": [
{
"rel": "self"
}
],
"items": [
{
"datetime_beginning_utc": "2023-01-01T00:00:00",
"pnode_id": 1269364670,
"total_lmp_rt": 25.611892,
"marginal_loss_price_rt": 0.132546
},
{
"datetime_beginning_utc": "2023-01-01T01:00:00",
"pnode_id": 1269364670,
"total_lmp_rt": 22.818414,
"marginal_loss_price_rt": 0.150509
}
]
},
"original": {
"priceType": "rt_hrl_lmps",
"pnodId": "1269364670",
}
}
]
Need to be transformed as below with only from "items" and "original". Need to combine both while adding "original" to all array elements in "items".
Any help is greatly appreciated.
Thanks
Manohar
[
{
"datetime_beginning_utc": "2023-01-01T00:00:00",
"pnode_id": 1269364670,
"total_lmp_rt": 25.611892,
"marginal_loss_price_rt": 0.132546,
"priceType": "rt_hrl_lmps",
"pnodId": "1269364670"
},
{
"datetime_beginning_utc": "2023-01-01T01:00:00",
"pnode_id": 1269364670,
"total_lmp_rt": 22.818414,
"marginal_loss_price_rt": 0.150509,
"priceType": "rt_hrl_lmps",
"pnodId": "1269364670"
}
]
08-22-2023 11:03 AM
Hi @manohar ,
Good day, try this expression $entity.get('items',[]).map(i=> i.merge($.get('original',{})))