Skip to content

Instantly share code, notes, and snippets.

@mvallebr
Created October 18, 2014 17:45
Show Gist options
  • Save mvallebr/8a715d7ad457debb748b to your computer and use it in GitHub Desktop.
Save mvallebr/8a715d7ad457debb748b to your computer and use it in GitHub Desktop.
Example showing how to read dict marshalled using str(dict) and print json
'''
Created on 18/10/2014
@author: mvalle
'''
from urllib2 import urlopen
import json
if __name__ == '__main__':
f = urlopen("https://gist.githubusercontent.com/anonymous/acbd70c0616e4225764c/raw/41e9b49faf122d346cce0b5bc12176e33874034a/gistfile1.txt")
try:
file_text = f.read()
finally:
f.close()
my_dict_var = eval(file_text)
print json.dumps(my_dict_var, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment