Json serialization with limited memory consumption
I have a simple decoder
val json = Json {
ignoreUnknownKeys = true
}
return jsonString?.let { json.decodeFromString(it) }
that works well until I got an error:
Fatal Exception: java.lang.OutOfMemoryError
Failed to allocate a 33554448 byte allocation with 6291456 free bytes and 18MB until OOM, target footprint 37003824, growth limit 50331648
So, I tried to use a stream:
jsonString?.let {
ByteArrayInputStream(it.toByteArray()).use { inputStream ->...