How to use default type value for RuntimeTypeAdapterFactory?
Open
enhancement
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
I found this code snippet, which checks existence of field `typeFieldName`:
https://github.com/google/gson/blob/ceae88bd6667f4263bbe02e6b3710b8a683906a2/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java#L222-L236
I wonder if there is any way to set default value for field `typeFieldName` when `deserialization` json string to java object? Or the only way is to override this method (basically copy and paste but provide the default value when there is none):
https://github.com/google/gson/blob/ceae88bd6667f4263bbe02e6b3710b8a683906a2/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java#L207
Contributor guide
Assessment
This issue has not been assessed yet.