djblets.webapi.encoders¶
-
class
WebAPIEncoder
[source]¶ Bases:
object
Encodes an object into a dictionary of fields and values.
This object is used for both JSON and XML API formats.
Projects can subclass this to provide representations of their objects. To make use of a encoder, add the path to the encoder class to the project’s
settings.WEB_API_ENCODERS
list.For example:
WEB_API_ENCODERS = ( 'myproject.webapi.MyEncoder', )
-
class
BasicAPIEncoder
[source]¶ Bases:
djblets.webapi.encoders.WebAPIEncoder
A basic encoder that encodes standard types.
This supports encoding of dates, times, QuerySets, Users, and Groups.
-
class
ResourceAPIEncoder
[source]¶ Bases:
djblets.webapi.encoders.WebAPIEncoder
An encoder that encodes objects based on registered resources.
-
class
JSONEncoderAdapter
(encoder, *args, **kwargs)[source]¶ Bases:
json.encoder.JSONEncoder
Adapts a WebAPIEncoder to be used with json.
This takes an existing encoder and makes it available to use as a json.JSONEncoder. This is used internally when generating JSON from a WebAPIEncoder, but can be used in other projects for more specific purposes as well.