Open vishalpatel-rf opened 11 months ago
Input json
[ { "e": "id1", "c": [ { "title": "title1", "enable": false } ] }, { "e": "id2", "c": [ { "title": "title2", "enable": true } ] } ]
want to create new property called filtered at same level as c that contains any item from c with enable property not set to false. So expected output is
filtered
c
enable
[ { "e": "id1", "c": [ { "title": "title1", "enable": false } ], "filtered": [] }, { "e": "id2", "c": [ { "title": "title2", "enable": true } ], "filtered": [ { "title": "title2", "enable": true } ] } ]
I am using following spec
[ { "operation": "shift", "spec": { "@": "&" } }, { "operation": "modify-default-beta", "spec": { "root": { "*": { "c": { "*": { "enable": true } } } } } }, { "operation": "shift", "spec": { "root": { "*": { "c": { "*": { "enable": { "true": { "@2": "[&5].filtered[]" } } } }, "@": "" } } } } ]
But it skips over the first element at top level completely and generate output like this
[ { "e" : "id1", "c" : [ { "title" : "title1", "enable" : true } ] }, { "e" : "id2", "c" : [ { "title" : "title2", "enable" : true } ], "filtered" : [ { "title" : "title2", "enable" : true } ] } ]
Will appreciate any help in getting the spec right.
Input json
want to create new property called
filtered
at same level asc
that contains any item fromc
withenable
property not set to false. So expected output isI am using following spec
But it skips over the first element at top level completely and generate output like this
Will appreciate any help in getting the spec right.