Skip to content

Instantly share code, notes, and snippets.

@greut
Forked from ask/gist:98452
Created April 20, 2009 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greut/98523 to your computer and use it in GitHub Desktop.
Save greut/98523 to your computer and use it in GitHub Desktop.
def test_json(encode, decode):
data = {
"foo": u"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)
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\u00e6x jomps \u00f8ver da l\u00e6zy d\u00e5g"}
DECODED: {'foo': u'The quick brown f\xe6x jomps \xf8ver da l\xe6zy d\xe5g'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment