Created
March 29, 2012 22:29
-
-
Save jcasts/2244392 to your computer and use it in GitHub Desktop.
Easy JSON command line parser
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
#! /bin/bash | |
# Prerequisite: | |
# $ gem install kronk | |
# Usage: | |
# json '{"foo": "bar"}' | |
# json example.com/foo.json | |
# echo '{"foo": "bar"}' | json | |
# See http://github.com/yaksnrainbows/kronk for more options | |
args=( "$@" ) | |
first=${args[0]} | |
fchar=${first:0:1} | |
if [[ "$fchar" == '{' || "$fchar" == '[' ]]; then | |
echo "$first" | kronk --parser json ${args[@]:1} | |
else | |
kronk --parser json $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment