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

[BUG] $filter returns a string when only one match #469

Open
amcdnl opened this issue Aug 10, 2020 · 3 comments
Open

[BUG] $filter returns a string when only one match #469

amcdnl opened this issue Aug 10, 2020 · 3 comments

Comments

@amcdnl
Copy link

amcdnl commented Aug 10, 2020

Bug

When you use the $filter and it only finds one match, it will return a string rather than an array.

The documentation states that it should return an array: https://docs.jsonata.org/higher-order-functions#filter

Steps

Here is a screenshot of a jsonata excise that shows the issue:

image

If I invert the expression so that it would return more, it works as expected returning an array.

image

I'm not sure if this is expected or not, but if it returns nothing, it returns undefined.

@andrew-coleman
Copy link
Member

Does this explain what you see? https://docs.jsonata.org/processing#sequences

Rather than paste a screenshot, please could you use the 'save and share' facility and paste in the link.

image

@mattbaileyuk
Copy link
Member

As discussed in https://docs.jsonata.org/next/construction#array-constructors you can use [ ] to ensure the result is always an array

@jhorbulyk
Copy link
Contributor

Related #462

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

No branches or pull requests

4 participants