본문 바로가기

JAVA/Error

[JAVA] Can not deserialize instance of '' out of START_OBJECT token Error - JSON 데이터 Map 변환 시 에러

 

 

이것도 타입 미스 에러이다.

 

Can not deserialize instance of '' out of START_OBJECT token

 

ObjectMapper mapper = new ObjectMapper();
Sample s = mapper.convertValue(data, Sample.class);

 

보통 ObjectMapper 사용 시 발생하는 에러인데,

 

mapper.convertValue
mapper.readValue

 

메서드 상관없이 발생한다.

타입이 달라서 발생했기 때문에.

 

JSON 데이터 전달 하는 쪽 (프론트) 과,

Entity(VO) 쪽 변수/객체 타입이 전부 일치하는지 확인하면 된다.

 

대부분은 List 형식인데 그냥 받아서 발생했더라.

배열 [] 인지 List 인지도 확인 하시길.

나는 List가 아닌데 List로 받아서 발생했다.

 

Reperance

 

https://www.baeldung.com/jackson-exception