OpenQuizz
Une application de gestion des contenus pédagogiques
JSONEncoder Class Reference
Inheritance diagram for JSONEncoder:
Collaboration diagram for JSONEncoder:

Public Member Functions

def default (self, o)
 

Detailed Description

The default Flask JSON encoder. This one extends the default
encoder by also supporting ``datetime``, ``UUID``, ``dataclasses``,
and ``Markup`` objects.

``datetime`` objects are serialized as RFC 822 datetime strings.
This is the same as the HTTP date format.

In order to support more data types, override the :meth:`default`
method.

Member Function Documentation

◆ default()

def default (   self,
  o 
)
Implement this method in a subclass such that it returns a
serializable object for ``o``, or calls the base implementation (to
raise a :exc:`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)
return JSONEncoder.default(self, o)

The documentation for this class was generated from the following file: