I'm currently struggling with some jq, hope somebody can help.Given is the following JSON structure:
[ {"id": "100","input": "ChecklistState","value": "-","sub": [ {"id": "110","input": "Text","value": "foo","sub": [] }, {"id": "120","input": "ChecklistState","value": "OK","sub": [] }, {"id": "130","input": "ChecklistState","value": "OK","sub": [] }, {"id": "140","input": "ChecklistState","value": "OK","sub": [] } ] }]I need a filter, that changes "value" to "OK" of the parent ("id": "100"), when every child in "sub" with "input" value "Text" has no empty "value" and every "input" value "ChecklistState" has value "OK". ( -> 110 not empty, 120, 130 and 140 "OK")
A generally usable filter (checking for the input) would be great, but I also wouldn't mind a solution, where I check for every child-ID individually.
I've tried accessing the values of the childs withselect(.sub[]?.id=="xxx").valueand concatenating that in an if-then-else-end-Block, however the results was, that the conditions seemed not to work.
Please note: due to software requirements, I need to use jq v1.5