Mateusz Kolbusz
06/29/2023, 10:23 AMExpected start of the array '[', but had 'EOF' instead at path: $
This code works properly on kotlin 1.7.20 but throws an exception on 1.8.21 (1.8.20 too)
inline fun <reified T> String.listFromJson() = json.decodeFromString<List<T>>(this)
In both cases I use the latest 1.5.1
library.
What different between versions?
Where I can find what changes have been made?Chris Lee
06/29/2023, 1:22 PMMateusz Kolbusz
06/29/2023, 2:47 PMinline fun <reified T> String.listFromJson(): List<T>? =
json.decodeFromString(json.parseToJsonElement(this).jsonPrimitive.content)
I have no idea why this worksChris Lee
06/29/2023, 2:51 PMinline fun <reified T> String.listFromJson() {
if( isEmpty()) {
return emptyList<T>()
}
return json.decodeFromString<List<T>>(this)
}
Chris Lee
06/29/2023, 2:52 PM