4 ms·
You should be able to do some pipe fu and carry out some form of merging via bash. I mostly use it for making our output more readable or producing CSV style re
by lugg 12y ago
You should be able to do some pipe fu and carry out some form of merging via bash. I mostly use it for making our output more readable or producing CSV style reports with the filtered data. Its filters are probably the biggest feature, at least in my mind.
- kolev 12y agoSorry for not being clear. I meant a merge in the form of {"a": 1, "b": 2, "c": 3} merged with {"b": 20} returning {"a": 1, "b": 20, "c": 3}. Like Python's update() or PHP's array_replace_recursive() although PHP's a little richer.
- cryptonector 12y agojq 'reduce .[] as $obj ({}; .+$obj)' or jq -s 'reduce .[] as $obj ({}; .+$obj)' should do it. `+` adds objects by merging them.
- kolev 12y agoThanks! I'm eager to try this and hopefully clean up my code!
- slapresta 12y agoIf you can code it using jq itself, you can submit a pull request and have it added to the builtins.