decodeOrNull

inline fun <T : Any> decodeOrNull(data: Any?): T?

Same as decode, but returns null instead of throwing when data is null or doesn't match T's expected shape.

Return

the decoded T, or null if data is null or decoding failed.

Parameters

data

the raw value to decode, or null.


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

Non-reified overload of decodeOrNull.

Return

the decoded T, or null if data is null or decoding failed.

Parameters

strategy

the serializer to decode with.

data

the raw value to decode, or null.