Merge Arrays of JSON

Let me also provide just what the title asks for, because I’m sure a lot of people that stepped on this question look for something simpler.

Any of the following (added math2001 and pmf answers):

echo -e '["a","b"]\n["c","d"]' | jq -s 'add'
echo -e '["a","b"]\n["c","d"]' | jq -s 'flatten(1)'
echo -e '["a","b"]\n["c","d"]' | jq -s 'map(.[])'
echo -e '["a","b"]\n["c","d"]' | jq -s '[.[][]]'
echo -e '["a","b"]\n["c","d"]' | jq '.[]' | jq -s

results in:

[
“a”,
“b”,
“c”,
“d”
]

Note: Also any of the above can apply to arrays of objects.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)