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
What is your use-case and why do you need this feature? JsonDecodingException: Expected class kotlinx.serialization.json.JsonObject (Kotlin reflection is not available) as the serialized body of F, but had class kotlinx.serialization.json.JsonLiteral (Kotlin reflection is not available)
This error message is not very helpful without the property name, but the name is available: currentTag.
To reproduce:
@Serializable
sealedinterfaceF {
@Serializable
@SerialName("a")
data classA(valf:F): F
}
Json.decodeFromString(F.serializer(), """{"type":"a", "f":"wrong-input"}""")
Describe the solution you'd like JsonDecodingException: Serial name f expected class kotlinx.serialization.json.JsonObject (Kotlin reflection is not available) as the serialized body of F, but had class kotlinx.serialization.json.JsonLiteral (Kotlin reflection is not available)
The text was updated successfully, but these errors were encountered:
…ent.
Such a code path is often used when we cannot find type discriminator as a first key in Json (for example, if json input is invalid, and we got a string instead of an object). In such cases, we should display a nice error message.
Also add tag stack — equivalent of a Json path — to most of the error messages. Note that it is far from an ideal, since changing between string and tree decoders (such happens in polymorphism) won't preserve stack or path correctly. Yet, it is the best we can do for now.
Fixes#2630
…ent. (#2648)
Such a code path is often used when we cannot find type discriminator as a first key in Json (for example, if json input is invalid, and we got a string instead of an object). In such cases, we should display a nice error message.
Also add tag stack — equivalent of a Json path — to most of the error messages. Note that it is far from an ideal, since changing between string and tree decoders (such happens in polymorphism) won't preserve stack or path correctly. Yet, it is the best we can do for now.
Fixes#2630
Co-authored-by: Sergey Shanshin <sergey.shanshin@jetbrains.com>
What is your use-case and why do you need this feature?
JsonDecodingException: Expected class kotlinx.serialization.json.JsonObject (Kotlin reflection is not available) as the serialized body of F, but had class kotlinx.serialization.json.JsonLiteral (Kotlin reflection is not available)
This error message is not very helpful without the property name, but the name is available:
currentTag
.To reproduce:
Describe the solution you'd like
JsonDecodingException: Serial name f expected class kotlinx.serialization.json.JsonObject (Kotlin reflection is not available) as the serialized body of F, but had class kotlinx.serialization.json.JsonLiteral (Kotlin reflection is not available)
The text was updated successfully, but these errors were encountered: