What is the most efficient way to de/serialize a `...
# getting-started
s
What is the most efficient way to de/serialize a
Set<Set<String>>
to String?
e
depends on what you mean by efficient and the values in use
using kotlinx.#serialization,
Json.encodeToString<Set<Set<String>>>(...)
and
Json.decodeFromString<Set<Set<String>>>(...)
are easy
without extra dependencies, if you have some unused chars, you could do
.joinToString(";") { it.joinToString(",") }
and
.splitToSequence(';').map { it.splitToSequence(',').toSet() }.toSet()
, or do that plus escaping
s
In terms of runtime, which is faster?
g
if you don’t have kotlinx.serialization on your project, just use joinToString If you do and performance matters for this case, just measure it