How to parse json objects not array using jq

Viewed 130

For example:

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

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

{"p":2}
1 Answers

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

jq -n input

or

jq -n 'first(inputs)'
Related