Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change path expression array handling rules #7

Open
shortercode opened this issue Nov 24, 2022 · 0 comments
Open

Change path expression array handling rules #7

shortercode opened this issue Nov 24, 2022 · 0 comments
Labels
JSONata compatibility Can either capture valid or invalid compatibility issues

Comments

@shortercode
Copy link
Collaborator

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 
@shortercode shortercode added the JSONata compatibility Can either capture valid or invalid compatibility issues label Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSONata compatibility Can either capture valid or invalid compatibility issues
Projects
None yet
Development

No branches or pull requests

1 participant