jq '.[]' code example

Example 1: jquery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

Example 2: get jq command

apt-get update && apt-get install jq	#Just install this way in UNIX

Example 3: jq filter array

$ json='[{"genre":"deep house"}, {"genre": "progressive house"}, {"genre": "dubstep"}]'
$ echo "$json" | jq -c '.[] | select(.genre | contains("house"))'
{"genre":"deep house"}
{"genre":"progressive house"}

Example 4: jquery

<script src="https://code.jquery.com/jquery-3.5.0.js"></script>

Example 5: jqery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

Example 6: jq list top nodes

echo '{"node1":"foo", "node2":"bar","node3": {"inner-node": "baz"}}' | jq '. |=keys'

[
  "node1",
  "node2",
  "node3"
]

Tags: