---
url: "https://vueda.dev/v3/reference/api/py/vueda.core.renderers/VuedaJSONEncoder.md"
title: "VuedaJSONEncoder"
---

# 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` {#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-signature}

`default(self, obj)`

#### Parameters {#default-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="default-param-obj">obj</span> |  | yes |  |  |

### Source {#default-source}

`server/vueda/core/renderers.py:32`

## Source

`server/vueda/core/renderers.py:22`
