Jq: Difference between revisions
From wikinotes
(Created page with "parse json on the commandline.") |
No edit summary |
||
Line 1: | Line 1: | ||
parse [[json]] on the commandline. | parse [[json]] on the commandline. | ||
= Documentation = | |||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| official docs || https://stedolan.github.io/jq/manual/ | |||
|- | |||
| homepage || https://stedolan.github.io/jq/ | |||
|- | |||
|} | |||
</blockquote><!-- Documentation --> | |||
= Usage = | |||
<blockquote> | |||
== Basics == | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
# print w/ syntaxhighlighting | |||
echo '{"one": 1, "two": {"a": "A"}}' | jq | |||
# get key ["one"] | |||
echo '{"one": 1, "two": {"a": "A"}}' | jq '.one' # 1 | |||
# get nested-key ["two"]["a"] | |||
echo '{"one": 1, "two": {"a": "A"}}' | jq '.two.a' # "A" | |||
# get list item at index 1 | |||
echo '["a", "b", "c"]' | jq '.[1]' # "b" | |||
</syntaxhighlight> | |||
</blockquote><!-- Basics --> | |||
</blockquote><!-- Usage --> |
Revision as of 15:17, 28 August 2021
parse json on the commandline.
Documentation
official docs https://stedolan.github.io/jq/manual/ homepage https://stedolan.github.io/jq/
Usage
Basics
# print w/ syntaxhighlighting echo '{"one": 1, "two": {"a": "A"}}' | jq # get key ["one"] echo '{"one": 1, "two": {"a": "A"}}' | jq '.one' # 1 # get nested-key ["two"]["a"] echo '{"one": 1, "two": {"a": "A"}}' | jq '.two.a' # "A" # get list item at index 1 echo '["a", "b", "c"]' | jq '.[1]' # "b"