IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
Deserializer Class Reference

Public Member Functions

None __init__ (self, SerializationType serialization_type=SerializationType.JSON)
 Initializes a deserializer instance.
 
IArchive read (self, TextIO stream)
 Reads serialized data from the given text stream and returns a reconstructed IArchive.
 

Protected Member Functions

None _populate_archive (self, Archive archive, list|dict data)
 Recursively populates an Archive with parsed JSON data.
 

Protected Attributes

 _type = serialization_type
 

Detailed Description

A deserializer that reads serialized data and reconstructs IArchive objects.

Currently, only JSON is supported.

Example::

deserializer = Deserializer()
with open("input.json", "r") as f:
    archive = deserializer.read(f)
archive.get("id", int) # 42
archive.get("name", str) # 'example'
Since
ids_peak_icv 1.0

Definition at line 12 of file deserializer.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self,
SerializationType serialization_type = SerializationType.JSON )

Initializes a deserializer instance.

Parameters
serialization_typeThe format to use for deserialization. Defaults to :class:SerializationType.JSON.
Since
ids_peak_icv 1.0

Definition at line 32 of file deserializer.py.

Member Function Documentation

◆ _populate_archive()

None _populate_archive ( self,
Archive archive,
list | dict data )
protected

Recursively populates an Archive with parsed JSON data.

Parameters
archiveThe archive to populate.
dataParsed JSON data (dict, list, scalar).
Exceptions
CorruptedExceptionIf the format of the given data is invalid.

Definition at line 75 of file deserializer.py.

◆ read()

IArchive read ( self,
TextIO stream )

Reads serialized data from the given text stream and returns a reconstructed IArchive.

Parameters
streamThe input stream to read from (e.g., file).
Returns
A new :class:Archive containing the deserialized data.
Exceptions
NotSupportedExceptionIf the serialization format is unsupported or the JSON is invalid.
IOExceptionIf the parsing fails.
Since
ids_peak_icv 1.0

Definition at line 46 of file deserializer.py.

Field Documentation

◆ _type

_type = serialization_type
protected

Definition at line 42 of file deserializer.py.