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

Is there a way to get the length for result of a path? #107

Closed
prashantagarwal opened this issue Nov 5, 2019 · 7 comments
Closed

Is there a way to get the length for result of a path? #107

prashantagarwal opened this issue Nov 5, 2019 · 7 comments

Comments

@prashantagarwal
Copy link

I have a JSON

{
    collection: [{
      prop: {}
    },{
      prop: 2
    }]
}

and I have the path as collection[*].prop@integer(). I want to know the size of the result, which should be 1 in this case.

@brettz9
Copy link
Collaborator

brettz9 commented Nov 5, 2019

Is there some reason you can't just get length on the resulting array?

@prashantagarwal
Copy link
Author

@brettz9 I am using JsonPath in a rule engine. I want to keep my path generic and therefore thought that it would be great if there is a way to do it.

@brettz9
Copy link
Collaborator

brettz9 commented Nov 5, 2019

@prashantagarwal : No, we still don't have the expressiveness of XPath (not to mention XQuery), though a PR would be welcome...

@prashantagarwal
Copy link
Author

@brettz9 Doing something like this will solve a lot of my use cases.

@brettz9
Copy link
Collaborator

brettz9 commented Nov 6, 2019

Though I haven't taken a close look, from a quick overview JSONata looks quite exciting...

@flodaniel
Copy link

Hello,

why was this issue closed?
This is quite a downfall, because filtering becomes a lot less powerful without being able to work with the result array afterwards..

@brettz9
Copy link
Collaborator

brettz9 commented Jul 6, 2020

The original poster perhaps closed it due to a relative lack of maintenance of this repository and my mentioning JSONata as an interesting looking project.

PRs would be welcome, but see #124 on our wishing to first see proposals be made as part of a standardization process so that different jsonpath implementations do not end up differing so much.

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

No branches or pull requests

3 participants