2 ms·
That task is trivially accomplishable in jq. I have no clue why you say it's "easier" in nodejs. i=1 for line in `echo '[{"a":"b"},{"c":"d"},{"e":"f"}]
by TheDong 12y ago
That task is trivially accomplishable in jq. I have no clue why you say it's "easier" in nodejs.
i=1
for line in `echo '[{"a":"b"},{"c":"d"},{"e":"f"}]' | jq '.[]' -c`; do
echo $line | jq '.' > jq_out_$i.json
i=$((i+1))
done
The above prints each element of the array to a file named by its index, including pretty-printing it.
If you use it every day, the above should have come to you easily enough.