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

Support for getting the length of an array. #100

Closed

Conversation

transparentech
Copy link

This commit allows you to use ".length" in a JSONPath to get the length of an array. This is supported by the Goessner implementation (according to the JsonPath Evaluator), but seems to be lacking in the Jayway implementation. For example, "$.store.book.length" returns 4.

I'm new to the JsonPath code so there is probably a better way of doing this. Feel free to make suggestions for improvement or alternate implementation.

@kallestenflo
Copy link
Contributor

Just tried it with the Goessner impl and as you say it works just fine. In my opinion it's a bit ambiguous, maybe more so in the java world. The Goessner implementation contains some features that I'm not sure about. Do you have a killer use case or is it just a nice to have?

@transparentech
Copy link
Author

We're using JsonPath as part of a testing framework which gets JSON documents as input and verifies their contents. Essentially, we have a list of JsonPath Paths that we execute on the JSON document and if they match the expected results, the test passes. Being able to get the length of an array in the JSON document is extremely useful in verifying the contents of the documents.

@kallestenflo
Copy link
Contributor

I will close this in favor of #103 that provides the same functionality but with a more generic approach.

@transparentech transparentech deleted the array-length-support branch February 22, 2016 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants