I need to perform a Jolt transformation on the below example json:
"treasure": [
{
"name": "FOO",
"value": 45
},
{
"name": "BAR",
"value": 20
},
{
"name":"FOOBAR",
"value":23
]
I need the output to look like:
{
"attributes" : {
"RAB" : 20,
"OOF" : 45,
"RABOOF":23
}
as you can see the BAR is replaced with RAB, FOO with OOF and FOOBAR replaced with RABOOF also used this replacement keys to map with the values in the input. I need to use a IF ELSE to make the replacement of the keys and also after replacing map the values to the keys accordingly What should be the spec here?
This is how far I reached
{
"operation": "shift",
"spec": {
"*": {
"treasure": {
"*": {
"name":{
"FOO":{
"#OOF":"treasure.name"
},
"BAR":{
"#RAB":"treasure.name"
},
"FOOBAR":{
"#RABOOF":"treasure.name"
}
}
}
},
"@(value)": "[&3].attributes.@(name)"
Check this spec,