google / google/gson

Gson is unable to serialise Kotlin subclass which overrides fields.

Open
#2,453 3 comments 0 reactions 0 assignees View on GitHub
enhancement kotlin
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

# 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.