Extend of this question: How to combine strings from JSON values, keeping only part of the string? Above link's output also include the "name" of folder type, need to exclude these "type":

           "date_added": "13170994909893393",
           "date_modified": "13184204204228233",
           "id": "2098",
           "name": "ElasticSearch",
           "sync_transaction_version": "1",
           "type": "folder"

How to get only field if "type" of the same object is "url", otherwise ignore:

A valid pattern that will be put in the output:

           "type": "url",
           "url": "https://url_here"

1 Answer 1


Given an array of objects, jq can select the ones that fulfil a certain criteria using select().

It sounds like you may want to use

.array[] | select(.type == "url")

Given a JSON document like

{ "array": [ { "type": "folder", "name": "example folder" },
             { "type": "url",    "name": "example url"    } ] }

the above query will return

  "type": "url",
  "name": "example url"

Not the answer you're looking for? Browse other questions tagged .