Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JsonDeserializationContext.deserialize overload with TypeToken parameter #2216

Open
Marcono1234 opened this issue Oct 2, 2022 · 0 comments
Labels
enhancement java8 Issues related to making Java 8 the minimum supported version

Comments

@Marcono1234
Copy link
Collaborator

Marcono1234 commented Oct 2, 2022

Problem solved by the feature

Similar to #1700 JsonDeserializationContext should have a deserialize overload with TypeToken parameter to provide type-safety, and the documentation should then recommend that overload.

Feature description

Since JsonDeserializationContext is an interface and might be implemented by users, the deserialize overload would have to be implemented as interface default method. Therefore this has to wait until Gson targets Java 8 or newer.
The default method could then simply delegate to the other overload, though Gson's internal implementation could override it to directly call Gson.fromJson(..., TypeToken).

Maybe it would also be worth considering to deprecate the existing method with Type parameter, see also #2328.

@eamonnmcmanus eamonnmcmanus added the java8 Issues related to making Java 8 the minimum supported version label Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement java8 Issues related to making Java 8 the minimum supported version
Projects
None yet
Development

No branches or pull requests

2 participants