Allow object-defined JSON serialization in JSONField/DjbletsJSONEncoder.

Review Request #8350 — Created Aug. 26, 2016 and submitted — Latest diff uploaded

Information

Djblets
release-0.10.x
86e6cd0...

Reviewers

DjbletsJSONEncoderallowed models to define a to_json() method, which
would be called when an instance of that model was encountered. Since
this is useful outside of models, the encoder's been updated to support
this on any object, making it much easier to encode content in places
like integration or site configuration storage.

JSONField has also been updated to make use of DjbletsJSONEncoder,
bringing those same benefits to any models that use that.

In order to keep all existing encoder usage from changing any behavior
with datetimes, DjbletsJSONEncoder now acceps a strip_datetime_ms
parameter, defaulting to True for compatibility reasons. JSONField
turns this off.

Unit tests pass.

Tested that a JSONField I was using in Review Board was able to
serialize an object with a to_json method.