Skip to content

Instantly share code, notes, and snippets.

@lamberta
Created October 22, 2010 16:34
Show Gist options
  • Save lamberta/640904 to your computer and use it in GitHub Desktop.
Save lamberta/640904 to your computer and use it in GitHub Desktop.
Command-line JSON
#get
curl -H 'Content-Type: application/json' url
#post
curl -H 'Content-Type: application/json' -X POST -d "{'foo':'bar'}}" url
#pretty print
curl -s -H 'Content-Type: application/json' url | python -m json.tool
#simple script, docs: http://docs.python.org/library/json.html
curl -s -H 'Content-Type: application/json' url | \
python -c "import sys, json; j = json.load(sys.stdin); print(j);"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment