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
Gson will be able to easily serialise subclasses with overridden fields.
Feature description
Gson is unable to serialise Kotlin subclass which overrides fields gives error multiple JSON fields named. Gson should ignore the parents value when a value gets overridden. Use childs name and value when serializing.
Alternatives / workarounds
Use transient keyword either in parent or child class.
The text was updated successfully, but these errors were encountered:
Could you show some code where this is a problem? Doesn't have to be real code, of course: if you can boil it down to a simple example that would be even better.
I do think that if you have a choice, Moshi is probably a better choice than Gson when working with Kotlin.
@SerializedName("page_context")
open val pageContext: PageContext,
)](url)
[ open class CommonEvent(
@SerializedName("page_context") @Transient override val pageContext: PageContext,)
](url)
Please check the code. Here Event is a parent class and CommonEvent is a subclass. CommonEvent overrides a variable pageContext. When you serialize it gives an error without transient keyword.
Problem solved by the feature
Gson will be able to easily serialise subclasses with overridden fields.
Feature description
Gson is unable to serialise Kotlin subclass which overrides fields gives error multiple JSON fields named. Gson should ignore the parents value when a value gets overridden. Use childs name and value when serializing.
Alternatives / workarounds
Use transient keyword either in parent or child class.
The text was updated successfully, but these errors were encountered: