Skip to content

[Java] Deserializing one pojo into another type #1998

@chaokunyang

Description

@chaokunyang

Feature Request

Continuing the discussion in #1972 (comment), we need to support deserializing one pojo into another type without the need to register class

Is your feature request related to a problem? Please describe

#1972

Describe the solution you'd like

Step1 Extend ClassDef to replace type

  /**
   * Return a new {@link ClassDef} by replacing {@code definedClass} of all fields and current {@link ClassSpec} in hierarchy 
   * from {@code cls} into {@code targetCls}.
   */
  public ClassDef replace(Class<?> cls, Class<?> targetCls) {

  }

Step2

  • Extend ClassResolver with a new readClassInfoWithMetaShare method with passed deserialized type
  • The readClassInfoWithMetaShare should return the original ClassDef first, then invoke ClassDef#replace to return a new ClassDef
  • Use that new ClassDef to create a new Deserializer to deserialize the data into passed deserialized type

Describe alternatives you've considered

No response

Additional context

#1996

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions