IDS peak ICV v1.6.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 specified stream and deserializes it into an archive.
 

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

Deserializer for reading serialized data and converting it into an IArchive object.

This class provides functionality to read data from a supported serialization format (currently, only JSON) and reconstruct it as an IArchive object.

Example

from ids_peak_icv.serialization import Deserializer, SerializationType

deserializer = Deserializer(SerializationType.JSON)
with open("archive.json", "r") as f:
    archive = deserializer.read(f)

id = archive.get("id", int)
name = archive.get("name", str)
Since
ids_peak_icv 1.0

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 SerializationType.JSON.
Since
ids_peak_icv 1.0

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
CorruptedExceptionThe format of the given data is invalid.
Since
ids_peak_icv 1.0

◆ read()

IArchive read ( self,
TextIO stream )

Reads serialized data from the specified stream and deserializes it into an archive.

Parameters
streamThe stream to read serialized data from.
Returns
An IArchive object containing the deserialized data.
Exceptions
NotSupportedExceptionThe serialization type is not supported.
IOExceptionThe parsing failed.
CorruptedExceptionThe format of the given data is invalid.
Since
ids_peak_icv 1.0

Field Documentation

◆ _type

_type = serialization_type
protected