Skip to content

json_query skips over arrays in path result #177

@bergmansj

Description

@bergmansj

The following snippet

    json test = json::parse(R"(
    {
      "books": [
        {"title": "b1", "chapters":[{"subtitle":"b1c1"}]},
        {"title": "b2", "chapters":[{"subtitle":"b2c1"}]}
      ]
    } )");
    json path_result = json_query(test, "$..[?(@.subtitle == 'b2c1')]", result_type::path);

    std::cout << path_result.to_string() << std::endl;

prints out

  ["$['books']['chapters'][0]"]

while I expected ["$['books'][1]['chapters'][0]"]

It seems that the path result skips array indices, which prohibits me from finding the location of the matched data item in the json structure.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions