🍃 𝗦𝗽𝗿𝗶𝗻𝗴 𝗕𝗼𝗼𝘁
[Springboot] 컨트롤러에서 Json 데이터 받을 때 오류 out of START_ARRAY token..Cannot deserialize value of type JsonToken..
비타민찌
2022. 4. 6. 15:55
728x90
Springboot 컨트롤러에서 Json 데이터 받을 때 오류 out of START_ARRAY token..Cannot deserialize value of type JsonToken..
Post 로 아래 데이터를 받으려고 하는데
컨트롤러에서 out of START_ARRAY token 에러가 났다.
[
{
"product_idx": 1,
"amount": 1
},
{
"product_idx": 2,
"amount": 2
}
]
에러가 났던 이유는 컨트롤에서 받아올때의 타입 문제였다..
public BaseResponse<Integer> order(@AuthenticationPrincipal UserLoginRes userLoginRes, @RequestBody List<PostOrderReq> postOrderReq) {
return new BaseResponse<>(0);
}
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class PostOrderReq {
List<PostOrderReq> postOrderReqs;
private String product_idx;
private String amount;
}
이렇게 하면 된다.
방금 누군가 기분이 상한듯한 댓글을 달았는데.. 제 프로젝트 코드 입니다!ㅋㅋ
클래스명과 변수명이 일반적이라 오해하셨을지도요.ㅎㅎ
지금은 댓글을 지우셨지만 나쁜 의도는 없었다는 점 알아주세요.^^
728x90