Jq
From wikinotes
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"Comments
Neither json nor
jq
support comments.
It's hacky, but you could pre-process the object to strip them, however.echo '{ // syntax-highlight as javascript "local_path": "/home/you", // your home dir // a network path "netwk_path": "//10.1.0.5/music" }' \ | sed 's?//[^"]*$??' | jq '.one'