Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unmarshal json body to list of myclass in camel

I'd like to know how to unmarshal JSON string body to List of MyClass. The following sample doesn't work well.

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

And I'd like to have something like (obviously doesn't work too)

from("direct:testroute")
.log("Received body ${body}")
.unmarshal().json(JsonLibrary.Jackson, List<MyClass>.class)
like image 350
Junior5413 Avatar asked Sep 25 '17 17:09

Junior5413


1 Answers

Create

JacksonDataFormat format = new ListJacksonDataFormat(MyClass.class);

and then:

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

source

like image 107
Adrian Avatar answered Nov 15 '22 11:11

Adrian