Running JSON logic on complex data objects with nested arrays is very awkward due to the fact that under most circumstances (other than with some array operations) var evaluations are applied to the entire data object.
I have thus introduced a new operator local that permits evaluation of its second argument to be scoped to the the results of the evaluation of the first argument only. This allows chaining logic by feeding results of one step to the next and makes complex evaluations easier to write and handle.
Taking an example from amended additional_operators.md:
Given data object:
Running JSON logic on complex data objects with nested arrays is very awkward due to the fact that under most circumstances (other than with some array operations) var evaluations are applied to the entire data object.
I have thus introduced a new operator local that permits evaluation of its second argument to be scoped to the the results of the evaluation of the first argument only. This allows chaining logic by feeding results of one step to the next and makes complex evaluations easier to write and handle.
Taking an example from amended additional_operators.md: Given data object:
If we want to find out the name of the first orchard that has more than 20 pear trees, we can now do:
Without local, to achieve the same we'd need to use this:
Now try asking with reduce for the second result and things quickly start getting unwieldy.
Raised as pull request #21