Skip to content

Unexpected empty array returned on expression rather than NULL #66

@richardgaunt

Description

@richardgaunt

I just wanted to confirm / point out that I am receiving back a value from the below method that is different from the code comments:

\JmesPath\Env::search($expression, $data);

https://github.com/jmespath/jmespath.php/blob/master/src/Env.php#L25

The document block states that I should @return mixed Returns the matching data or null receive matching data or null but I have found that when I utilise this with object or list projection like:

included[?type=='paragraph--basic_text'] as long as the included array exists in the JSON, it will return an empty array rather than a NULL value.

Can I confirm that this is the expected behaviour?

Checking the tutorial website I get the same result in different versions of jmespath.

Thank you very much for the package. I am utilising it in integration testing to evaluate json responses which is incredibly useful.

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