ppsc.parse.json package
A package for loading and storing Phenopacket Schema elements in JSON format.
- class ppsc.parse.json.JsonSerializer(**kwargs)[source]
Bases:
Serializer
A serializer to format
Serializable
objects into JSON format.The serializer will convert the field names from snake case used in Python into camel case (e.g. file_attributes -> fileAttributes). For the purpose of working with Phenopacket Schema, the serializer will not convert the map keys, (e.g. keys of file_attributes map).
See
json.dump()
for the accepted keyword arguments.- serialize(val: Serializable, fp: IO)[source]
Serialize a value val into the provided IO object fp.
- class ppsc.parse.json.JsonDeserializer[source]
Bases:
Deserializer
A deserializer to load
Deserializable
objects from JSON format.The deserializer supports reading a JSON with keys in both snake case (e.g. file_attributes) and camel case (e.g. fileAttributes).
- deserialize(fp: str | TextIOBase, clz: Type[D]) D [source]
Decode an instance of deserializable class from the input fp.
- Parameters:
fp – input to decode either as a str or a text IO handle.
clz – type of the class to be created from the input.
- Returns:
a new instance of D with attributes set based on the fp.