Python json
From wikinotes
TODO:
use and document the usageof simplejson
datatypes
JSON natively supports 6x datatypes:
// simple datatypes { "string" = "my string", "number" = 9999, "boolean" = true, "null" = null } // compound datatypes { "object" = { "a":1, "b":1 }, // a dictionary "array" = [ "a","b","c" ] }
write
my_dict = { 'a': 1, 'b': 2, } with open( filepath, 'w' ) as fw: fw.write( json.dumps(my_dict, indent=2) )
read
with open( filepath, 'r' ) as stream: my_dict = json.load(stream)