13

I have json like this:

[ {"one": 1}, {"two": 2}]

and wish to convert it to this format:

{"one": 1}
{"two": 2}

to facilitate indexing it into ElasticSearch. (latter is called 'jsonl' format). JQ is my tool of preference but I can't figure out how to do this. Thanks

peak
  • 105,803
  • 17
  • 152
  • 177
David
  • 485
  • 1
  • 5
  • 16

2 Answers2

29

The key is the -c command-line option, which produces JSONL:

jq -c '.[]' test_array.json
peak
  • 105,803
  • 17
  • 152
  • 177
-3

figured this out:

cat test_array.json |jq '.[]'
David
  • 485
  • 1
  • 5
  • 16