Skip to content

Change path expression array handling rules #7

@shortercode

Description

@shortercode

Path expressions use an automatic packing/unpacking algorithm in several places. It works on 2 equivalency rules, where any place one would be accepted the other must also. Also when resolving a value the latter is the preferred output.

[ value ] == value
[] == undefined

This means in some scenarios you will get a value or undefined instead of an array when the input data changes, making the expressions somewhat unpredictable.

I propose we modify this behaviour slightly to make it more predictable. We unfortunately cannot do this everywhere as it breaks some nice to haves.

  • path expressions will always resolve to an array.
  • field expressions will normally resolve to an array but may also resolve to the value of the only element or undefined.
  • wildcard expressions will normally resolve to an array but may also resolve to the value of the only element or undefined.
let output = ({ a: 1 }).a 

Metadata

Metadata

Assignees

No one assigned

    Labels

    JSONata compatibilityCan either capture valid or invalid compatibility issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions