AttachmentDataSerializer

The AttachmentDataSerializer is responsible for serializing and deserializing instances of AttachmentData.

To serialize an AttachmentData object, use the serialize function. This function takes an Encoder and the AttachmentData object to be serialized as parameters. It delegates the serialization to the appropriate serializer based on the type of the AttachmentData object. The supported types are:

  • AttachmentData.AttachmentHeader

  • AttachmentData.AttachmentJws

  • AttachmentData.AttachmentJwsData

  • AttachmentData.AttachmentBase64

  • AttachmentData.AttachmentLinkData

  • AttachmentData.AttachmentJsonData

To deserialize an AttachmentData object, use the deserialize function. This function takes a Decoder as a parameter. It first checks the JSON object read from the decoder to determine the type of the AttachmentData object. It then uses the appropriate deserializer to deserialize the JSON object into the corresponding AttachmentData subclass. The supported JSON object structures are:

  • { "children": ... } for AttachmentData.AttachmentHeader objects

  • { "protected": ..., "signature": ... } for AttachmentData.AttachmentJws objects

  • { "base64": ..., "jws": ... } for AttachmentData.AttachmentJwsData objects

  • { "base64": ... } for AttachmentData.AttachmentBase64 objects

  • { "links": ..., "hash": ... } for AttachmentData.AttachmentLinkData objects

  • { "data": ... } for AttachmentData.AttachmentJsonData objects

If the JSON object does not match any of the supported structures, a SerializationException is thrown.

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

This variable represents the descriptor for the AttachmentData class when it is serialized and deserialized. It is an instance of the SerialDescriptor class.

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): AttachmentData

Deserializes a JSON representation of AttachmentData into an AttachmentData object.

Link copied to clipboard
open override fun serialize(encoder: Encoder, value: AttachmentData)

Serializes the given AttachmentData object using the provided Encoder.