kotlinx.serialization
kotlinx.serialization copied to clipboard
Refine exception messages in case of deserializing data from JsonElement.
Such a code path is often used when we cannot find a type discriminator as a first key in Json (for example, if json input is invalid, and we get a string instead of an object). In such cases, we should display a nice error message.
Also, add a tag stack — the equivalent of a Json path — to most of the error messages. Note that it is far from 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