-
Notifications
You must be signed in to change notification settings - Fork 119
-
Notifications
You must be signed in to change notification settings - Fork 119
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
jsonpath as key accessor #90
Comments
I don't understand what this is meant to do. Can you explain? |
input:
jstl:
output:
$.content.container[*].component[?(@.type==1)].data.title is jsonpath expression |
I'm not sure what you're trying to do, but this gives you the output you want:
An even simpler solution is Not sure this is as general as you would like, though |
This is a very simplified document structure. Ideally, I would like to create a template for each type of component and use it in JSLT. But for this I should be able to get the JSON object by component type. Is there any other way to find a JSON object based on the value in it? |
Oh. Now I understand what you were doing.
Output of this would be:
|
Thank you. Now I implemented this as a function
but with jsonpath support it would be much easier. |
I agree something like XPath predicates would be good here. I've thought about this a few times. One way to do it would be to simply say that if the expression in square brackets produces boolean values then it's not array indexing, but instead a filter. With that rule you could write this as:
I'm not sure whether I like the ambiguity here, so it may be better to have a syntax that explicitly indicates what's going on. |
You could always use different characters. Curly braches: Your choice. |
Yes. I've considered this:
Reactions welcome. |
I prefer the first option. Reasoning:
However, I also like the curly braces I mentioned. |
Yeah, I think I agree. |
What happens if the expression does not evaluate to true/false, is it automatically false ? E.g. It would be an error in my world. |
We have automatic conversion to boolean other places in the language. One nice thing about that is that existence checks become very natural. Get me all the sub-objects which have the field
|
Great. The original question was, do you plan to support JSON path expressions, not just conditional expressions ? He asked for "jsonpath as key accessor", and gave a conditional example. I am happy with that. I just noticed this is a theoretical question. |
Well, I didn't understand the initial question, and I still don't, so I can't really answer it. What "JSON path expressions" are being asked for that the language doesn't have? |
is it possible use jsonpath as key accessor?
somethings like this:
The text was updated successfully, but these errors were encountered: