I want to get the Cartesian product of 2 lists, and tried following way:
echo [[1,2,3],[4,5,6]] | jq '[.[0][],.[1][]]'
I expected to get [[1,4],[1,5],[1,6],[2,4],[2,5],....], but what I really get is [1,2,3,4,5,6]
But using the following 2 commands, I get the Cartesian product output,
echo [[1,2,3],[4,5,6]] | jq '(.[0][] | tostring) + "," + (.[1][] | tostring)'
echo [[1,2,3],[4,5,6]] | jq '{"x": .[0][], "y": .[1][]}'
My questions is: why does comma behave differently from "+"? why does list constructor behave differently from object constructor?