-
Notifications
You must be signed in to change notification settings - Fork 35
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
Returning key of found object #46
Comments
This is not doable with JsonPath-PHP. I looked around and it does not seem to be part of the spec anywhere other than in the library backing the site you are sharing. If you check the readme it states that it is an addition, not provided in the spec. Aside from that, feel free to implement it and open a PR with it. We can discuss what it should work like and the edge cases. I tried doing:
Overall it seems to be a quirky functionality in the way it is implemented in that library. If we were to include it in JsonPath-PHP I'd expect a better definition (similar to how we included |
I do not insist in a particular solution, but I do have the problem to get the key of objects in the result set. Do you have an Idea of a workaround? The ^and ~ are proposed in https://github.com/JSONPath-Plus/JSONPath. There is one more thing which confuses me.
in https://extendsclass.com/jsonpath-tester.html both expressions yield the same results. |
I don't think it is possible to do the equivalent of
I remember thinking about this one for quite a while when I implemented the library. My conclusion was that
The logic behind this is that in the same way you can't do |
thanks for the hint wrt thanks for the explanation about |
As I've said before, I implemented this before there were the number of implementations that exist today. I don't have the time to update this library to match other implementations' features. Of course, PRs are very welcome 😄 |
with {"feldnamen": {
"familienname": {
"sample":"Bitter-Schwalenst\u00f6cker",
"ctabbildung":"dbfeld",
"ctmerkmalsgruppe":"",
"ctdbfeldnam":"name",
"ctfunktion":"ct_getnachname",
"cthinweis":""
}
}}
but This also happens in https://jsonpath.com/ but I cannot see why. So in datastructures which uses keys as values (such as |
In With I think the query you are looking for is |
hi @bwl21, Let me know if my last message solved your question. Regarding the Cheers! |
@Galbar thanks for asking, I did not answer yet since I am still trying around but did not get the full understanding. Nevertheless. What I want is the keys of all objects which have a property so I tried |
Hi @bwl21 I don't think there is a way to get the keys using this JSONPath implementation. I think the solution for this would be to add the I have an idea on how to implement the The idea would be to duplicate the access operators ( |
I am not sure if that is relevant to this issue but may be someone will find it useful: |
suppose I have
$..[?(@.v=="va")]
returnshow can I get the key of this object which is
a
?https://extendsclass.com/jsonpath-tester.html suports
~
, such that$..[?(@.v=="va")]~
returnsThe text was updated successfully, but these errors were encountered: