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

length not working well in jsonpath_examples.cpp #453

Open
MonkeybreadSoftware opened this issue Sep 24, 2023 · 0 comments
Open

length not working well in jsonpath_examples.cpp #453

MonkeybreadSoftware opened this issue Sep 24, 2023 · 0 comments
Labels

Comments

@MonkeybreadSoftware
Copy link
Contributor

The examples does this:

    // The number of books
    json result2 = jsonpath::json_query(booklist, "length($..book)");
    std::cout << "(2) " << result2 << "\n";

output is [1] as length gets passed an array of array and that outer array has value 1. But I think the examples like to output the number of books and not the number of result arrays.

I turned on a bit debugging:

length function arg: [[{"author":"Nigel Rees","category":"reference","price":8.95,"title":"Sayings of the Century"},{"author":"Evelyn Waugh","category":"fiction","price":12.99,"title":"Sword of Honour"},{"author":"Herman Melville","category":"fiction","isbn":"0-553-21311-3","price":8.99,"title":"Moby Dick"},{"author":"J. R. R. Tolkien","category":"fiction","isbn":"0-395-19395-8","price":22.99,"title":"The Lord of the Rings"}]]
(2) [1]

So either the example needs a new expression to query length value 4 or the code calling length needs to look into the array first?

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

No branches or pull requests

1 participant