Commits

Jason R. Coombs committed c9c1dc4

Bolstered the documentation and added some doctests.

Comments (0)

Files changed (2)

jaraco/json/main.py

+"""
+A JSON encoder and decoder with hooks for serializing basic objects.
+
+Native types should be encoded naturally.
+
+>>> encode('foo')
+'"foo"'
+>>> encode(15)
+'15'
+>>> encode({'mykey': 'myval'})
+'{"mykey": "myval"}'
+
+Also, custom objects can be encoded.
+>>> MyCustom = type('MyCustom', (), dict()) # an simple class
+>>> encode(MyCustom())
+'{"__python_module__": "jaraco.json.main", "state": "{}", "args": "[]", "__python_class__": "MyCustom"}'
+
+"""
+
 from __future__ import absolute_import
 # http://docs.python.org/library/json.html
 import json

jaraco/json/test_encoding.py

 	coll.append((1,2,3))
 	
 	serialized = encode(coll)
+	assert isinstance(serialized, basestring)
 	return serialized
 
 def test_decode_serialized():