0

I have old Pojos inside jar. Example;

   public class human implements Serializable {
   }

   public class Man extend human {
  } 

  public class Woman extend human {
  } 

I have json like {"type":"man",...}

I want to deserialize proper class using type But I cannot use these annotations because Base class generated automatically from xsd.

@JsonTypeInfo(// use = JsonTypeInfo.Id.NAME, // include = JsonTypeInfo.As.EXISTING_PROPERTY, // property = "queryType", // visible = true) @JsonSubTypes({ // @Type(value = ScenarioByCountryQuery.class, name = "scenarioByCountry"), // @Type(value = ScenarioByMeasureQuery.class, name = "scenarioByMeasure") })

I don want to desearlize like if type = '' etc. I want to deserialize dynamically using this type value.

  • 1
    Does this answer your question? [Jackson - deserialize using Builder without annotation](https://stackoverflow.com/questions/46903678/jackson-deserialize-using-builder-without-annotation) – Gregg Jun 25 '21 at 13:52
  • thank you but this is not my question answer – Muhammed şahsuvaroğlu Jun 25 '21 at 14:04
  • Try to use `MixIn` feature. Some examples: [MixIn method](https://stackoverflow.com/a/23255539/51591), [MixIn class](https://stackoverflow.com/a/19600499/51591) – Michał Ziober Jun 26 '21 at 09:41

0 Answers0