Skip to content

Latest commit

 

History

History
40 lines (24 loc) · 912 Bytes

json_codec.rst

File metadata and controls

40 lines (24 loc) · 912 Bytes

JSON Codec

Codec for serialising and de-serialising JSON data. Supports both array and objects for mapping into resources or collections of resources.

The JSON codec uses the :pysimplejson module if available and falls back to the :pyjson module included in the Python standard library.

odin.codecs.json_codec

Methods

load

loads

dump

dumps

Customising Encoding

Serialisation of Odin resources is handled by a customised :pyjson.Encoder. Additional data types can be appended to the :pyodin.codecs.json_codec.JSON_TYPES dictionary.

Example usage

Loading a resource from a file:

from odin.codecs import json_codec

with open('my_resource.json') as f:
    resource = json_codec.load(f)