Positional Binding - issue using array constructor to generate array of arrays in result
oatybiscuit opened this issue · 0 comments
oatybiscuit commented
I use positional binding a lot in mapping arrays, eg foo#$bar.{"value": $, "index": $bar}. In some recent code, generating an array within the mapping iteration I wanted the final result to be an array of arrays, thus used an array constructor '[]' after the '.' mapping, as in array.[$] which generates an array of arrays [ [], [], [] ] as expected.
Adding a positional binding variable so as to be able to use the mapping positional index, the array of array collapses, and the array constructor no longer operates.
- Should the use of a positional binding at a mapping cause a failure of a post-mapping array constructor in this way?
- Why (after a great deal of experimentation) does the use of [[ ]] in place of [ ] cause the expected array of results to return?
https://try.jsonata.org/SJItcKMKA
Interestingly I have now learnt that array.[[$]] returns an array of array of arrays... There seems no end to the fun that can be had from JSONata!