{
"restaurantId" : 1,
"score" : 5,
"context" : "good!",
"detailReviews" : [
{"foodName":"kimchi", "context" : "good1", "score" : 3},
{"foodName" : "ramen", "context" : "good2", "score" : 4}
]
}
다음과 같이 리뷰 업로드를 하려는데 리뷰 안에 각 음식에 대한 리뷰가 따로 json array로 구성되어 있다.
그러면 DTO를 작성 시에 클래스 안에 클래스 구조를 갖어야 한다.
@Data // lombok
public class ReviewToUpload {
private Integer restaurantId;
private Integer score;
private String context;
private List<DetailReviewToUpload> detailReviews;
@Data
private static class DetailReviewToUpload {
private String foodName;
private String context;
private Integer score;
}
}
기본적으로 클래스의 List를 사용하면 된다.
주의점 !! - 꼭 내부 클래스에 static을 붙여야 한다!
안붙이면 에러난다. 이거 때문에 많은 시간을 소모했다.