$ brew install jq
With json that looks like this:
[
[
{
"id": 19,
"display_name": "Bono Bks",
"internal_name": "bono_bks",
"created_at": "2013-08-14T12:38:24.000-04:00",
"updated_at": "2014-04-25T14:14:36.000-04:00",
"display_order": 0,
"seo_name": "bono-bks",
"visible_in_browse": false,
"short_name": null,
"is_disabled": true,
"region_id": 1,
"common_name": null,
"email_name": null,
"scrapable": null,
"base_url": null,
"dynamic": false,
"common_display_name": "Bono Bks",
"commission_rate": null,
"partner_submittable": null,
"promotable": null,
"subscribable": null
},
...
]
]
You can get the display_name
, region_id
, and retailer_id
of all retailers where region_id == 1
with this:
$ jq ".[] | \
select(.region_id==1) | \
{display_name: .display_name, region_id: .region_id, id: .id}" \
retailers.json
{
"display_name": "Bono Bks",
"region_id": 1,
"id": 19
}
{
"display_name": "Coffee Time",
"region_id": 1,
"id": 31
}
{
"display_name": "DeeperShop",
"region_id": 1,
"id": 32
}
{
"display_name": "Versent",
"region_id": 1,
"id": 33
}
{
"display_name": "Copia",
"region_id": 1,
"id": 34
}
{
"display_name": "Author",
"region_id": 1,
"id": 28
}
{
"display_name": "All Romance",
"region_id": 1,
"id": 9
}
...