JsonSaver

fun <T> JsonSaver(json: Json, serializer: KSerializer<T>, delegate: Saver<String>, recover: suspend (Exception) -> T? = { e -> // TODO: Compiler bug does not permit inlining this delegate.recover(e)?.let { json.decodeFromString(serializer, it) } }): Saver<T>

A Saver implementation that will transform the given state to a JSON string before passing it to the delegate. It will use the specified json instance and serializer to transform the state. By default it will recover by trying the delegates' recover first, but if deserialization fails, it will throw.