-
Notifications
You must be signed in to change notification settings - Fork 140
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
[Recommendation] Support Handlebars-Esque Data Traversal #91
Comments
I've implemented this functionality in an alternative module, I'm going to close this ticket for now. An example use case for this style of traversal is here: {
"map": [
{
"var": "arr"
},
{
"+": [
{
"var": "../../a"
},
{
"var": ""
}
]
}
]
} {
"arr": [
1,
2,
3
],
"a": 2
} To produce |
That's great. |
@ivan133 Heh, sorry about that. There were a few things I wanted to be able to support (async logic, compilation for native-js performance, data traversal), and it would've required a significant overhaul to support. The alt module is 90% compatible with json-logic-js according to its test suite. The differences are subtle, like preferring |
I really like this module (and the json-logic language he designed), and I may try to contribute to it, but I had to make some rather aggressive tweaks to support some of the goals I had in mind. |
I really understand it.
I've noted your project and will try to switch to it in my spare time. For now, I've created my own fork of json-logic with custom operation mapWithScope that passes an object with 2 keys: the LOOP_VAR and ROOT_DATA. |
Hello,
I'm creating an "issue" to propose a recommendation & get your feedback. If you approve of the concept, I could probably follow through implementing it & create a PR.
In Handlebars, when you traverse down datasets, you can access data from the previous layer by utilizing
../
JSONLogic currently scopes the data strictly to the object you're performing an operation on, somewhat limiting its functionality (if my understanding is incorrect, I apologize).
Therefore it is quite difficult to do something like map over two arrays & create permutations.
Because JSONLogic currently supports traversing objects downwards using dot notation, I propose the
../
operation be considered as well.I do realize this affects how the iterative operators pass data down.
If you'd like, I could pursue implementing this functionality.
Thanks!
The text was updated successfully, but these errors were encountered: