vendredi 19 février 2021

Custom mapping complex DTO to another simpler DTO Spring Boot

I would like to map my complexDto to my QuestionAndAnswerDto such that questionLabel is the name of the property ex. "property_one" and the answer is the value of the property.

I tried using Reflection API and other multiple things like flattening the JSON. At this point, I believe that my approach is wrong. Is there a way to handle this? I couldn't find anything on stackoverflow.

public class QuestionAndAnswerDto {

private String questionLabel;
private String answer;

}

public class ComplexDto {

private List<Object1> property_one;
private Object2 property_two;
private String property_three;

}

public class Object1 {

private String property_four;

}

public class Object2 {

private String property_five;

}





Aucun commentaire:

Enregistrer un commentaire