tomchristie/django-rest-framework — pull request #1749 by jialichen (2014-08-11 13:16:41+00:00)
Title: add json.dumps and json.loads hook

Add properties for json.dumps and json.loads functions in JSONParser
and JSONRenderer class respectively. The classes can be easily extended
by providing custom dumps and/or loads functions.

When working with MongoDB and PyMongo, the data retrieved from the database contains some types that json.dumps and json.loads can't deal with. However, bson module, which comes with PyMongo, provides two wrap functions bson.json_util.dumps and bson.json_util.loads that solve the problem. By providing the hooks, the JSONParser and JSONRenderer can be easily extended to deal with it.