get

inline suspend fun <reified T> Store.get(namespace: List<String>, key: String, json: Json = Json): T?

Returns the value under key in namespace as a T, which a Json of json reads, or null when there is none. T is a @Serializable class or a basic type.

@Serializable
data class Diet(val name: String, val avoids: List<String>)

val diet = store().get<Diet>(listOf("preferences"), "diet")

A String is read as it was put, without JSON, so that it matches Store.put with a String.

Throws

when the value cannot be read as a T.