Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Created May 27, 2014 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkuchiki/89ddb0dd9cdb863316fc to your computer and use it in GitHub Desktop.
Save tkuchiki/89ddb0dd9cdb863316fc to your computer and use it in GitHub Desktop.
json 文字列を受けとって、任意のキーの値を出力する
$ echo '{"hosts":[{"name":"host1"},{"name":"host2"}]}' | python -c "exec(\"import json,sys\\nj=json.load(sys.stdin)\\nfor attr in j.get('hosts'):\\n    print attr.get('name')\")"
host1
host2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment