jslt
jslt copied to clipboard
Implement array traversal operator?
In this stackoverflow question someone wants to extract from each object in an array a key from each element in an array inside the first object.
It ends up having to be implemented like this:
flatten([for (.) [for (.locations) .state]])
However, if we allowed path expressions to iterate over an array and access elements of the array, like jq does with .[]
we could write the same thing as:
.[].locations.[].state
which I think is nicer and more natural.
I've been thinking about this extension almost since JSLT was created, but have been waiting for a concrete use-case. Now it seems there is one. Thoughts?
Discussion #191 shows another example with a need for this operator.