Serializer

interface Serializer<T>

Converts values of type T into their textual representation in a given mimeType (e.g. JSON, YAML, XML). This is the building block for scenarios such as persisting values to disk, sending them over a network, or exchanging them with tools written in other languages.

A typical implementation first turns each value into a plain object via an Objectifier, then hands that object to a format-specific writer (e.g. a Jackson ObjectMapper on the JVM).

Type Parameters

T

the type of values this serializer can serialize.

See also

for the inverse operation.

Inheritors

Properties

Link copied to clipboard
abstract val mimeType: MimeType

The textual format this serializer produces.

Functions

Link copied to clipboard
abstract fun serialize(value: T): String

Serializes a single value into its textual representation in mimeType.

Link copied to clipboard
abstract fun serializeMany(values: Iterable<T>): String
open fun serializeMany(values: Sequence<T>): String
open fun serializeMany(vararg values: T): String

Serializes several values into a single textual representation of all of them.