diff options
| author | Wayne Witzel III <wwitzel3@gmail.com> | 2012-03-28 12:03:52 -0400 |
|---|---|---|
| committer | Wayne Witzel III <wwitzel3@gmail.com> | 2012-03-28 12:06:58 -0400 |
| commit | ba60524b56a639ecad42f85b63af2120d9d96cdc (patch) | |
| tree | d4f2c2e374c80a14790f9c4940e88602b29ef1fc /docs/narr | |
| parent | d81ea33ac67ac750053acbfd12616db0130de3c8 (diff) | |
| download | pyramid-ba60524b56a639ecad42f85b63af2120d9d96cdc.tar.gz pyramid-ba60524b56a639ecad42f85b63af2120d9d96cdc.tar.bz2 pyramid-ba60524b56a639ecad42f85b63af2120d9d96cdc.zip | |
JSON-API rework and Object.__json__ support
Diffstat (limited to 'docs/narr')
| -rw-r--r-- | docs/narr/renderers.rst | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index 47182c09e..52e97d091 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -212,6 +212,13 @@ to :func:`json.dumps` by overriding the default renderer. See :class:`pyramid.renderers.JSON` and :ref:`_adding_and_overriding_renderers` for more information. +Custom objects can be easily serialized by defining a :func:`__json__` method +on the object. This method should return values serializable by +:func:`json_dumps`. By defining this method and using a :term:`JSON` +renderer the :class:`pyramid.renderers.ObjectJSONEncoder` class will be used +for encoding your object. If you later define your own custom encoder it will +override :class:`pyramid.renderers.ObjectJSONEncoder`. + You can configure a view to use the JSON renderer by naming ``json`` as the ``renderer`` argument of a view configuration, e.g. by using :meth:`~pyramid.config.Configurator.add_view`: |
