Serialization
JSON
- belso.serialization.json_format.to_json(schema, file_path=None, schema_name='')[source]
Serialize
schemain JSON format.Args
schema (
Type[Schema]): schema to serialize.file_path(Optional[Union[str, Path]], optional): path to save the JSON file.schema_name(str, optional): prefix to apply to the root schema name.
Returns
Dict[str, Any]: dict JSON-ready representation ofschema.
- belso.serialization.json_format.from_json(json_input, schema_name='')[source]
Load JSON (string / file / dict) into a belso Schema.
Args
json_input (
Union[str, Path, Dict[str, Any]]): JSON input to load.schema_name(str, optional): prefix to apply to the root schema name.
Returns
Type[Schema]: belso Schema loaded from JSON input.
YAML
- belso.serialization.yaml_format.to_yaml(schema, file_path=None, schema_name='')[source]
Serialise
schemato YAML.schema_nameis applied once to the root schema only; children keep their own names untouched.Args
schema (
Type[Schema]): schema to serialise.file_path (
Optional[Union[str, Path]]): path to save the YAML file.schema_name (
str): prefix to apply to the root schema name.
Returns
str: YAML representation ofschema.
- belso.serialization.yaml_format.from_yaml(yaml_input, schema_name='')[source]
Load YAML (string / file / dict) into a belso Schema.
schema_nameis applied only to the root schema name.Args
yaml_input (
Union[str, Path, Dict[str, Any]]): YAML input.schema_name (
str): prefix to apply to the root schema name.
Returns
Type[Schema]: schema deserialised fromyaml_input.
XML
- belso.serialization.xml_format.to_xml(schema, file_path=None, schema_name='')[source]
Serialise
schemato XML.schema_nameis applied once to the root schema only; children keep their own names untouched.Args
schema (
Type[Schema]): schema to serialise.file_path (
Optional[Union[str, Path]]): path to save the XML file.schema_name (
str): prefix to apply to the root schema name.
Returns
str: XML representation ofschema.
- belso.serialization.xml_format.from_xml(xml_input, schema_name='')[source]
Load XML (string / file / Element) into a belso Schema.
schema_nameis applied only to the root schema name.Args
xml_input (
Union[str, Path, ET.Element]): XML input.schema_name (
str): prefix to apply to the root schema name.
Returns
Type[Schema]: schema deserialised fromxml_input.