I have a JSON with the following content:
{
\"data\": [
{
\"name\": \"Test\",
\"program\": {
\"publicAccess\": \"--------\",
Your problem is when type == "array"
is true .
will be an array so .userGroupAccesses
won't work. What you want to do is focus on the case when .
is an object. In your call to walk
you only need to check for type == "object"
and then remove the members you don't want. e.g.
walk(if type == "object" then del(.publicAccess, .userGroupAccesses) else . end)
Try it online at jqplay.org
You can also solve this without walk
by using Recursive Descent .. e.g.
del(.. | .publicAccess?, .userGroupAccesses?)
Try it online at jqplay.org