1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Make null + foo return foo, rather than an error.

This also allows 'add' to be implemented in jq rather than C.
This commit is contained in:
Stephen Dolan
2012-12-29 16:50:58 +00:00
parent d5fdf70434
commit e0cda536f3
3 changed files with 29 additions and 18 deletions

View File

@@ -356,6 +356,9 @@ sections:
the key-value pairs from both objects into a single
combined object. If both objects contain a value for the
same key, the object on the right of the `+` wins.
`null` can be added to any value, and returns the other
value unchanged.
examples:
- program: '.a + 1'
@@ -364,6 +367,12 @@ sections:
- program: '.a + .b'
input: '{"a": [1,2], "b": [3,4]}'
output: ['[1,2,3,4]']
- program: '.a + null'
input: '{"a": 1}'
output: ['1']
- program: '.a + 1'
input: '{}'
output: ['1']
- program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'
input: 'null'
output: ['{"a": 42, "b": 2, "c": 3}']