JQ - Json Parser

Table of Contents

Cheatsheet for simple usage.

simple.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "id":"01234567",
  "active":true,
  "name":{
    "first":"John",
    "last":"Siu"
  },
  "address": [
    "address line 1",
    "address line 2",
    "address line 3"
  ]
}
Command Usage
jq '.' simple.json Print pretty
jq '.id' simple.json Print value of id
jq -r '.id' simple.json Print value of id, without quote
jq '.id, .active' simple.json Print value of id and active
jq '.name.last' simple.json Print value of last in name
jq '.address[0]' simple.json Print first item of array address
John Siu
Minimize the Effort, Maximize the Effect!
comments powered by Disqus