Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform array from array #84

Open
manishs747 opened this issue Aug 14, 2018 · 1 comment
Open

Transform array from array #84

manishs747 opened this issue Aug 14, 2018 · 1 comment

Comments

@manishs747
Copy link

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"
}
]
}

@mainpart
Copy link

mainpart commented Apr 7, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants