You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can't make kotlinx-serialization to decode a list of objects from a JSON string. If I use responseString and 'manually' decode from the resulting string, it works.
To Reproduce
Steps to reproduce the behavior:
Below are two blocks of code, first doesn't work, second does.
@Serializable
data classStore(valstoreID:String)
// does not workval (request, response, data) =Fuel.get(address)
.awaitObjectResponse<List<Store>>(
kotlinxDeserializerOf()
)
// does workval httpAsync =Fuel.get(address)
.responseString { request, response, result ->
result.fold({ d ->val obj = json.decodeFromString<List<Store>>(d)
println(obj[0].name)
}, { e ->println(e.message)
})
}
Expected behavior
Should deserialize string.
Actual behavior
Throws the exception below.
Exception stack:
Exception in thread "main" Expected class kotlinx.serialization.json.JsonObject (Kotlin reflection is not available) as the serialized body of kotlinx.serialization.Polymorphic<List>, but had class kotlinx.serialization.json.JsonArray (Kotlin reflection is not available)
com.github.kittinunf.fuel.core.FuelError$Companion.wrap(FuelError.kt:86)
com.github.kittinunf.fuel.core.DeserializableKt.awaitResponse(Deserializable.kt:258)
Caused by: kotlinx.serialization.json.internal.JsonDecodingException: Expected class kotlinx.serialization.json.JsonObject (Kotlin reflection is not available) as the serialized body of kotlinx.serialization.Polymorphic<List>, but had class kotlinx.serialization.json.JsonArray (Kotlin reflection is not available)
kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:94)
kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:81)
kotlinx.serialization.json.Json.decodeFromString(Json.kt:95)
MainKt$test$$inlined$kotlinxDeserializerOf$1.deserialize(FuelSerialization.kt:55)
Environment
IntelliJ IDEA Community
The text was updated successfully, but these errors were encountered:
Bug Report
Description
Can't make kotlinx-serialization to decode a list of objects from a JSON string. If I use responseString and 'manually' decode from the resulting string, it works.
To Reproduce
Steps to reproduce the behavior:
Below are two blocks of code, first doesn't work, second does.
Expected behavior
Should deserialize string.
Actual behavior
Throws the exception below.
Exception stack:
Environment
IntelliJ IDEA Community
The text was updated successfully, but these errors were encountered: