-
Notifications
You must be signed in to change notification settings - Fork 54
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 parameters and/or parent/root level objects #279
Comments
There's an alias called 'root' for accessing properties from root element/input, if that's what you want. That feature is not documented though... PS: #valueof path was always an absolute path, $ was a reference to input's root, I don't recall if it still behaves that way... |
Great! I will try what you suggested and reply with my results ASAP. |
Hi Courela, Just confirmed that #valueof path always the absolute one. This is exactly what I need for now. Also, I tried $ reference to the input root, with Thanks, |
Dollar sign refers to the root/start of the element being processed, as described in JsonPath. For #valueof function, it's always the whole input, but if you're in a loop, every other function will reference the element being processed, if no alias is specified. If you want to refer to a property/element outside the loop, you can use alias, being 'root' a special alias that references whole input. Usually, the transformation returns null if there's an error, one can change that creating a transformer using EvaluationMode.Strict
|
Hi Courela, Than you very much for your suggestion. using EvaluationMode.Strict just help me identified the root cause of an issue - only an actual value allowed in the following condition where I'm trying to compare a value from #valueof or #currentvalueatpath, Input: Transformer: I used the first example of valueof to illustrate my use case of feeding #valueof as the 2nd comparator. How to handle dynamic values in the above sample? Thanks, |
You have to use #concat/#xconcat to make a dynamyc expression/path to #valueof { "result": { "Open": "#valueof(#xconcat($.menu.popup.menuitem[?/(@.value == ',#valueof($.open),'/)].onclick))", "Close": "#valueof(#xconcat($.menu.popup.menuitem[?/(@.value == ',#valueof($.close),'/)].onclick))" } } Note that you have to escape parenthesis inside the dynamic expression, or they will be considered as a function open/close instead of a character of a string .menuitem[?/(@.value Two notes:
|
I’m expecting a feature of supporting parameters assigned with internal or external json fragments in the same way as in XSLT. One of the use cases is to use such parameterized objects inside #loop. Or it’ll service the same purpose if providing a mechanism to access root/parent level fragments.
I am not able to find similar functionality in the current code base.
The text was updated successfully, but these errors were encountered: