Created
April 20, 2009 09:24
-
-
Save ask/98452 to your computer and use it in GitHub Desktop.
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
data = { | |
"foo": "The quick brown fæx jomps øver da læzy dåg", | |
} | |
x = encode(data) | |
print("ENCODED: %s" % x) | |
e = decode(x) | |
print("DECODED: %s" % e) | |
import simplejson | |
import cjson | |
test_json(simplejson.dumps, simplejson.loads) | |
test_json(cjson.encode, cjson.decode) | |
""" | |
Output: | |
TESTING JSON simplejson | |
ENCODED: {"foo": "The quick brown f\u00e6x jomps \u00f8ver da l\u00e6zy d\u00e5g"} | |
DECODED: {'foo': u'The quick brown f\xe6x jomps \xf8ver da l\xe6zy d\xe5g'} | |
TESTING JSON cjson | |
ENCODED: {"foo": "The quick brown f\u00c3\u00a6x jomps \u00c3\u00b8ver da l\u00c3\u00a6zy d\u00c3\u00a5g"} | |
DECODED: {'foo': u'The quick brown f\xc3\xa6x jomps \xc3\xb8ver da l\xc3\xa6zy d\xc3\xa5g'} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment