Skip to content

Path Operator on empty array returns *no data* which doesn't work nicely with boolean function #718

Open
@vuquocbao

Description

@vuquocbao

Hello,

I'm running into an issue where performing a . operator on an empty array returns no data.

Example:
Lets say I have a json like this

{
   "myList": []
}

If I do an expression like this $boolean(myList) I get false.

But if I do something like this $boolean(myList.someVar) I get undefined.

This causes some problems because lets say the list contains a JsonObject. The second expression only works if there is at least one object in the list.

Note that if I use the $count function instead of the boolean it will always return 0.

I also encounter this problem when filtering.

So if I do something like this myList[type = 'SomeType']. If the list is empty that returns undefined or no data in the online editor. If there is at least one item that matches the filter it gets returns. If there is no items that matches it returns undefined.

But I think the biggest problem is how $boolean does work for undefined results like javascript. Ideally calling $boolean should return false if the filtering or path operation on the array results in undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions