Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 524

Delete all where DOES NOT contain

$
0
0

I have this JSON file json1.json:

{"a":"val1","b":"val2","nest1": {"z": "x","test": "containval"    }}

I need to get a new json where elements whose values that contain val are removed, ANY property can have val, this gets me close:

jq 'del(.. | select(. == "val1"))' .\json1.json

it produces this:

{"b": "val2","nest1": {"z": "x","test": "containval"  }}

Except that it checks for values being EQUAL to val1, and I only need where the value DOES NOT CONTAIN "val".

Desired output:

{"a":"val1","b":"val2","nest1": {"test": "containval"    }}

Viewing all articles
Browse latest Browse all 524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>