2017-09-25 3 views
1

JSON 문자열 본문을 List of MyClass에 unmarshal하는 방법을 알고 싶습니다. 다음 샘플은 제대로 작동하지 않습니다.json body를 낙타의 myclass 목록에 unmarshal하는 방법

from("direct:testroute") 
.log("Received body ${body}") 
.unmarshal().json(JsonLibrary.Jackson, List.class) 

그리고 내가 좋아하는 뭔가 (명백하게도 작동하지 않습니다)

from("direct:testroute") 
.log("Received body ${body}") 
.unmarshal().json(JsonLibrary.Jackson, List<MyClass>.class) 

답변

3

다음

JacksonDataFormat format = new ListJacksonDataFormat(MyClass.class); 

및 작성해야 싶습니다

//... 
.unmarshal(format) 
//... 

source

+0

또한 json 데이터 형식에 useList 옵션이 있습니다. –