Skip to content
Discussion options

You must be logged in to vote

The problem is, you serialize your toml into Index.Main:

val serializedIndex =
        Toml.encodeToString(
            serializer(),
            Index.Main(indexArray),
        )

And then you're trying to deserialize the result to List<Index.Main>.

The correct solution for you is:

fun readIndex() {
    if (File("index.toml").exists()) {
        val index: Index.Main = TomlFileReader.decodeFromFile(serializer(), "index.toml")
        index.files.forEach {
            println(it)
        }
    } else {
        exitProcess(0)
    }
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nellePoint
Comment options

@BOOMeranGG
Comment options

@nellePoint
Comment options

Answer selected by nellePoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants