Created
September 5, 2012 08:46
-
-
Save 1900/3633505 to your computer and use it in GitHub Desktop.
simplejson Encoding demo
This file contains hidden or 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
>>> import simplejson as json | |
>>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) | |
'["foo", {"bar": ["baz", null, 1.0, 2]}]' | |
>>> print json.dumps("\"foo\bar") | |
"\"foo\bar" | |
>>> print json.dumps(u'\u1234') | |
"\u1234" | |
>>> print json.dumps('\\') | |
"\\" | |
>>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True) | |
{"a": 0, "b": 0, "c": 0} | |
>>> from StringIO import StringIO | |
>>> io = StringIO() | |
>>> json.dump(['streaming API'], io) | |
>>> io.getvalue() | |
'["streaming API"]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment