How to overwrite the value of banana to null
Input
{
"fruits": [
"apple",
"banana",
"cherry"
]
}
Desired Output:
{
"fruits": ["apple", null, "cherry"]
}
You can use the conditional logic by separating the components of the array by the ones those are counterparts of banana
vs. others within a shift transformation such as
[
{
"operation": "shift",
"spec": {
"fruits": {
"*": {
"banana": { "@": "&3[&2]" },
"*": { "@1": "&3[&2]" }
}
}
}
}
]
the demo on the site https://jolt-demo.appspot.com/ is :