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

Singleton operator has no effect on an array of objects #236

Closed
DaelDe opened this issue Jun 14, 2018 · 3 comments · Fixed by #267
Closed

Singleton operator has no effect on an array of objects #236

DaelDe opened this issue Jun 14, 2018 · 3 comments · Fixed by #267
Labels

Comments

@DaelDe
Copy link

DaelDe commented Jun 14, 2018

Consider the following input:

[
{"type":"command"},
{"type":"commands"}
]

and expression $[type='command']. It returns the first object properly. However, I want to use the singleton operator to have easier handling: $[][type='command'] does not return an array of matches and $[type='command'][] does neither.
How can I always return an array of results in my case?

@DaelDe DaelDe changed the title Singleton array has no effect on an array of objects Singleton operator has no effect on an array of objects Jun 14, 2018
@jhorbulyk
Copy link
Contributor

[$[type='command']] does what you are looking for.

@andrew-coleman
Copy link
Member

This is a bug and is related to the second paragraph of this comment. I'll fix this.

@DaelDe
Copy link
Author

DaelDe commented Jun 15, 2018

@jhorbulyk indeed but I am not sure if this is intended behavior of jsonata, from reading the docs I am not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants