kazaam icon indicating copy to clipboard operation
kazaam copied to clipboard

Transform array from array

Open manishs747 opened this issue 6 years ago • 1 comments

Specks to transform array to array. array length will be dynamic.

eg:

{ "prices": [ { "name": "Journey Mileage", "type": "BASE", "tax": "V20", "amount": 30, "rate": 2.5, "unit": "miles", "charge": 75 } ] }

output: { "charges": [ { "amount": "2095", "currency": "EUR", "type": "price_base" } ] }

manishs747 avatar Aug 14 '18 05:08 manishs747

something like

[
{
operation : shift,
spec: {
field_newname : field_oldname,
field_newname1 : field_oldname1,
},
over: "prices[*]"
},
{
operation: shift
spec:{
output : prices
}
}
]

first section will replace original prices keys with new ones, forming an array of objects with only specified keys (with new key names and values from that old keys). second shift will bring every line mentioned to new top-level json

mainpart avatar Apr 07 '22 10:04 mainpart