MapTypeAdaptor ignores custom typeadaptor when writing keys
Open
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
`MapTypeAdaptor` uses whatever `TypeAdapter` is registered for a type to read it in — thus allowing a custom adapter to deserialize the key type; however, when writing out the keys, it simply calls `toString`, as seen [here](https://github.com/google/gson/blob/1f803bd37de5890f6da53f0b1a1b631eea4d1b8f/gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java#L207).
This limitation exists to ensure that the key is output properly as a string (via `out.name`) instead of an arbitrary JSON objects. Unfortunately, this undermines any custom type adapter which would like to use a different format.
Contributor guide
Assessment
This issue has not been assessed yet.