This generates a list of arrays:
$ echo -e "a 1\nb 2" | jq -R 'split(" ")'
[
"a",
"1"
]
[
"b",
"2"
]
When I slurp the input I get an array:
$ echo -e "a 1\nb 2" | jq -R 'split(" ")' | jq -s .
[
[
"a",
"1"
],
[
"b",
"2"
]
]
But when I try to convert the list into an array without slurping it, I get a list of arrays instead of a single array:
$ echo -e "a 1\nb 2" | jq -R '[split(" ")]'
[
[
"a",
"1"
]
]
[
[
"b",
"2"
]
]
Is it possible to slurp the result of the split
without piping the result into a new instance of jq
?