Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error decoding map: key is not a valid map index #287

Open
bj0 opened this issue Dec 7, 2024 · 7 comments
Open

error decoding map: key is not a valid map index #287

bj0 opened this issue Dec 7, 2024 · 7 comments

Comments

@bj0
Copy link

bj0 commented Dec 7, 2024

I tried this:

val d = mapOf("key" to "value")
val t = Toml.encodeToString(d)

Toml.decodeFromString<Map<String,String>>(t)

It throws an IllegalArgumentException: key is not a valid map index.

This seems so simple that maybe I'm using it wrong?

It works fine with Json serialization.

@matytyma
Copy link

What does t look like?

@bj0
Copy link
Author

bj0 commented Dec 17, 2024

it was key = "value"

@matytyma
Copy link

Hmmm doesn't encodeToString produce any extra newlines etc.? Did you try Toml.decodeFromString<Map<String,String>>("""key = "value"""")?

@bj0
Copy link
Author

bj0 commented Dec 17, 2024

I'm doing this in a kotlin scratch file, if that matters.

val d = mapOf("key" to "value")
val t = Toml.encodeToString(d)
println("encoded: '$t'")

try {
    Toml.decodeFromString<Map<String, String>>("""key = "value"""")
} catch (t: Throwable) {
    t.toString()
}

output is encoded: 'key = "value"' and the same exception is thrown on decode.

@matytyma
Copy link

That definitely is a bug in the decoding process, I'd have to look at the source in an IDE to see where it is thrown from. I haven't used ktoml for a while as I've hit a roadblock bug and had to migrate to tomlkt...

@orchestr7
Copy link
Owner

orchestr7 commented Dec 21, 2024

Yeah, right now I am very lazily support this project, hope I will have some time to return back to it.
If you need this bugfix very urgently - the only thing you can do is to make a patch for it if it is possible for you 😢

@matytyma
Copy link

Sure, I'll dig into it once I find some free time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants