I have this JSON input:
{
"input": {
"a": "valueA",
"b": "valueB",
"c": "valueC"
},
"fieldsToFilterBy": [
"a",
"c"
]
}
and i want to have this output:
{
"input": {
"a": "valueA",
"b": "valueB",
"c": "valueC"
},
"filteredValues": [
"valueA",
"valueC"
]
}
How can I obtain this using JOLT operations? I’ve tried many ways but nothing works all the way
2
Answers
You can try the following spec:
This basically will work if ValueA,ValueB, ValueC…etc. can never be 1 or 0. If they can then it wont work and there is another way which might get little more complex.
You can use a shift transformation spec in which
:
, and double{
) the tree in orderto reach
"input"
object’s level and.&
notation to replicate theleaf nodes’ values
filteredValues
in this case ) on RHSsuch as
the demo on the site http://jolt-demo.appspot.com/ is