dicogis.export.to_json module

JSON serializer.

class dicogis.export.to_json.MetadatasetSerializerJson(flavor='dicogis', localized_strings=None, output_path=None, opt_size_prettify=True)

Bases: MetadatasetSerializerBase

Export to JSON.

__init__(flavor='dicogis', localized_strings=None, output_path=None, opt_size_prettify=True)

Store metadata into JSON files.

as_udata(metadataset)

Serialize metadaset in a data structure matching udata dataset schema.

Parameters:

metadataset (MetaDataset) – input metadataset to serialize

Return type:

dict

Returns:

serialized as dict

json_encoder_for_unsupported_types(obj_to_encode)

Encode objects which are not serializable as they are by json.dump. Typically: pathlib.Path.

Parameters:

obj_to_encode (object) – object to encode in JSON

Return type:

str

Returns:

encoded object as string

serialize_metadaset(metadataset)

Serialize input metadataset as JSON file stored in output_path.

Parameters:

metadataset (MetaDataset) – metadataset to serialize

Return type:

Path

Returns:

path to the generated JSON file