background:
there is a member variable f in the model (Request) that receives client requests, which needs to be instantiated into different instances (An or B) for different business types (type).
public abstract class Father {
}
public class A extends Father {
private String a1;
private String a2;
}
public class B extends Father {
private String b1;
private String b2;
}
public class Request {
private Father f;
private String type; // typefAB
}
the current solution is to receive it directly with a JSONObject in the request model, and then convert it to a concrete instance.
public class Request {
private JSONObject f;
private String type; // typefAB
}
excuse me, how to configure (or how to do) in springboot so that the code of json- > A can be omitted? I cast it directly into a concrete instance in the rest of the business.
or is there any other better solution to deal with similar problems?
Thank you all for your generous advice.