Search code examples
jsonjqjsonlines

Can jq produce output without newlines between fields, one line per record?


jq always produces output with newlines/returns between each field:

jq ... foo.json
{
  "Name": "stedolan",
  "RecordTimestamp": "2021-02-25T05:00:06.740+0000"
}

How can I make the output one line per record so that it looks like:

{"Name":"stedolan","RecordTimestamp":"2021-02-25T05:00:06.740+0000"}

Solution

  • jq has an option for this: --compact-output

    jq --compact-output ... foo.json
    {"Name":"stedolan","RecordTimestamp":"2021-02-25T05:00:06.740+0000"}
    

    Full manual https://stedolan.github.io/jq/manual/v1.6/