Using jq to parse and display multiple fields in a json serially Using jq to parse and display multiple fields in a json serially json json

Using jq to parse and display multiple fields in a json serially


I recommend using String Interpolation:

jq '.users[] | "\(.first) \(.last)"'

reference


You can use addition to concatenate strings.

Strings are added by being joined into a larger string.

jq '.users[] | .first + " " + .last'

The above works when both first and last are string. If you are extracting different datatypes(number and string), then we need to convert to equivalent types. Referring to solution on this question. For example.

jq '.users[] | .first + " " + (.number|tostring)'


jq '.users[]|.first,.last' | paste - -