sample input json:
{
"parent1": {
"child2": "value"
}
}
currently, if i don't want to show a non-existing field, i will use "#ifgroup(#exists(" function combination.
Consider this transformer:
{
"t_parent1": {
"#ifgroup(#exists($.parent1.child1))" : {
"t_child1": "#valueof($.parent1.child1)"
},
"#ifgroup(#exists($.parent1.child2))" : {
"t_child2": "#valueof($.parent1.child2)"
}
}
"t_parent2": {
"#ifgroup(#exists($.parent2.child1))" : {
"t_child1": "#valueof($.parent2.child1)"
},
"#ifgroup(#exists($.parent2.child2))" : {
"t_child2": "#valueof($.parent2.child2)"
}
}
}
this will output:
{
"t_parent1": {
"t_child2": "value"
},
"t_parent2": {
}
}
now, if i don't want t_parent2 to be visible in the current output since it has no child, is it possible in just.net to remove it considering other inputs might include parent2 with child nodes?
like
{
"#ifgroup(#exists($.parent2.child1) **OR** #ifgroup(#exists($.parent2.child2))": {
"parent2" {
...
}
}
}