Any way we can use if else conditions in Jolt Transform :
Input :
{ "treasure": [ { "aname": "FOO", "bname": "BAR" } ] }
Output :
If aname is “FOO” then change to fname else let it be to aname.
{ "fname" : "FOO", "sname" : "BAR" }
Advertisement
Answer
Jolt Spec for If – Else:
[ { "operation": "shift", "spec": { "treasure": { "*": { "aname": { "FOO": { "@(2,aname)": "aname" }, "*": { "@(2,aname)": "gname" } }, "bname": { "BAR": { "@(2,bname)": "bname" }, "*": { "@(2,bname)": "gname" } } } } } } ]