Skip to content

Jayway's JsonPath returns empty array if key in the predicate is not present in JSON Data #352

@jimsha

Description

@jimsha

I am trying evaluate a JSON text using the expression $.sessions[?(@.key=='session3')].value using Jayway JsonPath 2.2.0 library.
JsonText = {
"username": xyz,
"empid": "1",
"sessions": [{
"key": "session1",
"value": "java"},
{
"key": "session2",
"value": "C"}]
}

It return empty object instead of null even if I am using Option.DEFAULT_PATH_LEAF_TO_NULL

I tried evaluating this through http://jsonpath.herokuapp.com/ and there also it returns empty array. Please help

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