niprov.formatjson module

class niprov.formatjson.DateTimeAwareJSONDecoder(**kwargs)

Bases: json.decoder.JSONDecoder

Converts a json string, where datetime and timedelta objects were converted into objects using the DateTimeAwareJSONEncoder, back into a python object.

dict_to_object(d)
class niprov.formatjson.DateTimeAwareJSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)

Bases: json.encoder.JSONEncoder

Converts a python object, where datetime and timedelta objects are converted into objects that can be decoded using the DateTimeAwareJSONDecoder.

default(obj)
class niprov.formatjson.JsonFormat(dependencies)

Bases: niprov.format.Format

Helper to convert provenance data to and from json encoded strings.

deserialize(jsonRecord)

Convert one provenance item from its json string version to the native python dictionary format.

Parameters:jsonRecord (str) – The provenance item to convert as json-encoded string.
Returns:Python dictionary of the provenance.
Return type:dict
deserializeList(jsonListOfRecords)

Convert a list of provenance items from its json string version to the a list of the native python dictionary format.

Parameters:jsonListOfRecords (str) – The provenance items to convert as json-encoded string.
Returns:Python list of dictionaries of the provenance.
Return type:list
serializeList(listOfRecords)

Convert a list of provenance items from its native list of python dict type to a json string.

Parameters:listOfRecords (list) – The provenance items to convert.
Returns:Json version of the provenance items.
Return type:str
serializeSingle(record)

Convert one provenance item from its native python dict type to a json string.

Parameters:record (dict) – The provenance item to convert.
Returns:Json version of the provenance.
Return type:str