Created
December 12, 2017 12:46
-
-
Save britishben/8d8ddd9d9f647e0407e8b312041c501a to your computer and use it in GitHub Desktop.
Returns a single field from a json textfile - The example I use has the format {"msg":{"key":"value",...}}
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
#Usage: jsonread.py <json_filename> <field> | |
import json | |
import sys #just for arguments | |
from pprint import pprint | |
with open(sys.argv[1]) as data_file: | |
data=json.loads(data_file.read()) | |
pprint(data['msg'][sys.argv[2]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment