Reputation: 804
this is a simple question,I am new to nifi and jolt. I just wanted to know,how to travserse the jolt spec while using wild card characters.For example,this is an example in jolt demo site,
input is
{
"data": {
"1234": {
"clientId": "12",
"hidden": true
},
"1235": {
"clientId": "35",
"hidden": false
}
}
}
Spec is
[
{
"operation": "shift",
"spec": {
"data": {
"*": {
"hidden": {
"true": {
// if hidden is true, then write the value disabled to the RHS output path
// Also @(3,clientId) means lookup the tree 3 levels, to the "1234" or "1235" level,
// and then come back down down the tree and grabe the value of "clientId"
"#disabled": "clients.@(3,clientId)"
},
"false": {
"#enabled": "clients.@(3,clientId)"
}
}
}
}
}
}
]
and output is
{
"clients" : {
"12" : "disabled",
"35" : "enabled"
}
}
How did we get the above output? like what @(3,clientsid).As far as I understand, it goes 3 levels up.But 3 levels with respect to what..the spec or the input? Either way,how to move 3 levels up,can you please define which are the levels here?
Thanks in advance
Upvotes: 2
Views: 230
Reputation: 65278
Just count the number of each opening curly-braces({
) or colons(:
) in the backward direction. Whenever they're not independent such as :{
, then count this as only one in order to reach to the target key which is "*"
wildcard just under "data"
key in this case, and for @(3,clientId)
; first level is crossing the colon(:
) next to "#disabled"
or "#enabled"
, second level is crossing opening curly-braces next to those boolean keys for each, and then the third level is crossing opening curly-brace just after "hidden"
key to reach the indexes the object with the "data"
key.
Upvotes: 2