1

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>

shaktiman_droid
  • 2,368
  • 1
  • 17
  • 32
Anhdevit
  • 1,926
  • 2
  • 16
  • 29

1 Answers1

4

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.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220