adobe / json-formula

Query language for JSON documents
http://opensource.adobe.com/json-formula/
Apache License 2.0
19 stars 8 forks source link

include null values in list/array construction #85

Closed JohnBrinkman closed 11 months ago

JohnBrinkman commented 11 months ago

Inherited from JMESPath, we have the behavior where an array/list construction will omit null entries. e.g. this expression: `[null, 1, 2, 3]`[*] yields: [1,2,3]

It would be more consistent (less surprising) if we included null values. If users want to omit them, they can apply a filter. e.g. `[null, 1, 2, 3]`[?@ != null()]

JohnBrinkman commented 11 months ago

Where some people might prefer the JMESPath behaviour is with this scenario. Given: [{"a": 1}, {"a": 2}, {"a":3}, {"b": 1}]

the expression: [*].a currently returns: [1, 2, 3] But with this change will return: [1, 2, 3, null]

The former result can be found by using a predicate something like: [?contains(keys(@),"a")].a or [*].a | [?@ != null()]

JohnBrinkman commented 11 months ago

fixed