0

How can jq get convinced to return results in one row? Without any options, the results get formatted

 echo '{"name":"New release","description":"Super nice release","milestones":["v1.0","v1.0-rc"]}' | jq '.milestones'

[
  "v1.0",
  "v1.0-rc"
]

I would like to have it in one row:

 echo '{"name":"New release","description":"Super nice release","milestones":["v1.0","v1.0-rc"]}' | jq '.milestones'

["v1.0","v1.0-rc"]

til
  • 832
  • 11
  • 27
  • 2
    IMO, this is a straightforward reference from the jq manual. The self-answer is not adding anything new to already existing text – Inian Dec 11 '20 at 12:42
  • except that google doesnt find anything, when I'm searching for it. Now there's a phrase close to the question out there to be captured. – til Dec 11 '20 at 12:51
  • google: `jq output on a single line` – peak Dec 11 '20 at 22:22

1 Answers1

1

From the manual

    --compact-output / -c:

By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line.

can stand in front and behind the filter

 echo '{"name":"New release","description":"Super nice release","milestones":["v1.0","v1.0-rc"]}' | jq -c '.milestones'

["v1.0","v1.0-rc"]

 echo '{"name":"New release","description":"Super nice release","milestones":["v1.0","v1.0-rc"]}' | jq '.milestones' -c 

["v1.0","v1.0-rc"]

til
  • 832
  • 11
  • 27