![]() |
IDS peak ICV v1.1.0
|
Public Member Functions | |
| None | __init__ (self, SerializationType serialization_type=SerializationType.JSON) |
| Initializes a new serializer with the given serialization type. | |
| None | write (self, IArchive archive, TextIO stream) |
| Serializes an IArchive object and writes it to the given stream. | |
Data Fields | |
| dict | _type = self._to_dict(archive) |
Protected Member Functions | |
| dict | _to_dict (self, IArchive archive) |
| Recursively converts an IArchive into a plain Python dict. | |
Protected Attributes | |
| _type = serialization_type | |
A serializer that converts IArchive objects into a textual representation.
Currently, only JSON is supported.
Example::
from ids_peak_icv.serialization.archive import Archive
archive = Archive()
archive.set("name", "example")
serializer = Serializer()
with open("input.json", "w") as f:
serializer.write(archive, f)
Definition at line 12 of file serializer.py.
| None __init__ | ( | self, | |
| SerializationType | serialization_type = SerializationType.JSON ) |
Initializes a new serializer with the given serialization type.
| serialization_type | The output serialization format. Defaults to :class:SerializationType.JSON. |
Definition at line 33 of file serializer.py.
|
protected |
Recursively converts an IArchive into a plain Python dict.
| archive | The archive to convert. :returns: A dictionary representation of the archive, suitable for serialization. |
Definition at line 72 of file serializer.py.
| None write | ( | self, | |
| IArchive | archive, | ||
| TextIO | stream ) |
Serializes an IArchive object and writes it to the given stream.
| archive | The archive to serialize. |
| stream | A writable text stream (e.g., file or StringIO). |
| NotSupportedException | If the configured serialization type is not supported. |
Example::
archive = Archive()
archive.set("id", 42)
serializer = Serializer(SerializationType.JSON)
with open("output.json", "w") as f:
serializer.write(archive, f)
Definition at line 47 of file serializer.py.
|
protected |
Definition at line 43 of file serializer.py.
| dict _type = self._to_dict(archive) |
Definition at line 66 of file serializer.py.