All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dtea.carcadex.1.2.0.source-code.CarcadeX.kt Maven / Gradle / Ivy

There is a newer version: 2.0.1-BETA
Show newest version
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import me.redtea.carcadex.kotlin.extensions.load
import me.redtea.carcadex.kotlin.extensions.repo
import me.redtea.carcadex.kotlin.extensions.save

data class SomeDomain(val tag: String, var age: Int, var balance: Float)

fun main() {
    val domainRepo = repo {
        save {
            Json.encodeToString(it)
        }
        load {
            Json.decodeFromString(it)
        }
    }
    domainRepo["key1"] = SomeDomain("key1", 1, 100.0f)
    domainRepo["key2"] = SomeDomain("key2", 2, 200.0f)
    domainRepo["key3"] = SomeDomain("key3", 3, 300.0f)
    domainRepo.saveAll()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy