decode

inline fun <T : Any> decode(data: Any): T

Decodes data as T via the framework's MosaicSerializer, using T's own generated KSerializer — for a builder that needs to interpret an opaque AnySerializable field (already a raw JSON-shaped value, not a JSON string) as a concrete type.

Return

the decoded T.

Parameters

data

the raw value to decode — typically an AnySerializable field's own content.

Throws

if data doesn't match T's expected shape — see decodeOrNull for a non-throwing variant.


fun <T> decode(strategy: KSerializer<T>, data: Any): T

Non-reified overload of decode, for a caller supplying its own KSerializer rather than relying on T's generated one.

Return

the decoded T.

Parameters

strategy

the serializer to decode with.

data

the raw value to decode.