Skip to content

Add JsonDeserializationContext.deserialize overload with TypeToken parameter #2216

@Marcono1234

Description

@Marcono1234

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementjava8Issues related to making Java 8 the minimum supported version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions