Is it possible to ignore/null a field during gson.fromJson if field type is incorrect?
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
I've encountered an issue where our server returns an incorrect response and during our call to `gson.fromJson()`, gson throws an IllegalStateException. This is a specific edge case that we normally don't encounter (our calls are generally wrapped in a try/catch for this exception). Ideally, we'd like `gson.fromJson()` to fail gracefully when encountering a type mismatch, setting that field to null instead of throwing an exception and causing a crash/the whole response to be null. Is there existing functionality/a way to achieve this? If not, is this something that could be added to gson in the future?
[jrp9988](https://github.com/jrp9988) can provide more info on the issue if needed.
Contributor guide
Assessment
This issue has not been assessed yet.