0

This question already has an answer here:

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"

marked as duplicate by JigglyNaga, Romeo Ninov, roaima, RalfFriedl, Fabby Nov 30 '18 at 20:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

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 or ask your own question.