Last active
January 13, 2018 16:21
-
-
Save putnamhill/b3d1ce4e91faffc5da25e6389db586fc to your computer and use it in GitHub Desktop.
collection of miscellaneous jq snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print value pairs from an array in lower case | |
jq --raw-output '.[] | "\(.key_1 | ascii_downcase) \(.key_2 | ascii_downcase)"' | |
# convert `key=value` lines into `{"key":"value"}` json | |
jq --raw-input 'split("=") | {(.[0]):.[1]}' some.conf | jq --slurp 'add' | |
# validate json (bad) | |
echo '{hello: "there"}' | jq . >/dev/null 2>&1 && echo good json || echo bad json | |
bad json | |
# validate json (good) | |
echo '{"hello": "there"}' | jq . >/dev/null 2>&1 && echo good json || echo bad json | |
good json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment