My resialized is "{"2":"Hello","Tesst":"Value"}"
I tried to parse this string to Map<String,String>
val resialized = readFile(createStorageDirectoryPath(getManifestFilePath()), MANIFEST_FILE_NAME, errorOut)
manifest = Json.decodeFromString(/*serializer*/, resialized)
How I create a serializer for Map<String,String>
You can use an other version of decodeFromString which will take care of deserializer by itself.
import kotlinx.serialization.decodeFromString
val res = Json.decodeFromString<Map<String, String>>("{\"2\":\"Hello\",\"Tesst\":\"Value\"}")
It's marked with ExperimentalSerializationApi, but I had no problems using it for the last year. This method is recommended by documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With