Home > Software engineering >  How to parse json objects not array using jq
How to parse json objects not array using jq

Time:11-26

For example:

echo '{"p":2}{"q":3}' | jq '.'

How do I select the first object? I want the object below:

{"p":2}

CodePudding user response:

You would use the -n command-line option, e.g.:

jq -n input

or

jq -n 'first(inputs)'
  • Related