4 ms·
Sorry 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 upda
by kolev 12y ago
Sorry 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.