VuedaJSONEncoder
Overview
DRF's JSON encoder, with durations as a number of seconds rather than a string.
Everything else is inherited. super() still decides what each type becomes, so a type DRF learns to encode later is encoded that way here too; only the timedelta result is converted, and it is parsed back from DRF's own representation rather than recomputed, so the two cannot disagree about which unit is meant.
default
Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).
For example, to support arbitrary iterators, you could implement default like this::
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# Let the base class default method raise the TypeError
return super().default(o)
Signature
default(self, obj)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| self | yes | |||
| obj | yes |
Source
server/vueda/core/renderers.py:32
Source
server/vueda/core/renderers.py:22