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
load
loads
dump
dumps
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.
Loading a resource from a file:
from odin.codecs import json_codec
with open('my_resource.json') as f:
resource = json_codec.load(f)