Python Json Cheat Sheet
Table of Contents
Overview
docs of python
The standard library documentation for this module.
JavaScript Object Notation
JSON home, with documentation and implementations in other languages.
simplejso
simplejson, from Bob Ippolito, et al, is the externally maintained development version of the json library included with Python 2.6 and Python 3.0.
jsonpickle
jsonpickle allows for any Python object to be serialized into JSON.
PyMoTW Howto
More Examples
Load and Decoded
import json data = [ { 'a':'A', 'b':(2, 4), 'c':3.0 } ] data_string = json.dumps(data) print 'ENCODED:', data_string decoded = json.loads(data_string) print 'DECODED:', decoded print 'ORIGINAL:', type(data[0]['b']) print 'DECODED :', type(decoded[0]['b'])
$ python json_simple_types_decode.py ENCODED: [{"a": "A", "c": 3.0, "b": [2, 4]}] DECODED: [{u'a': u'A', u'c': 3.0, u'b': [2, 4]}] ORIGINAL: <type 'tuple'> DECODED : <type 'list'>