Reputation: 2319
I have created a RequestRoute which extends RouteBuilder
:
@Component
public class RequestRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("file:input?noop=true").to(User.class);
}
And in the main class, I have added the route created above to Camel context:
@SpringBootApplication
public class DemoApplication {
@SneakyThrows
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RequestRoute());
}
}
How can I get a JSON object
from a file inside the folder and transform it to a Class using Camel
routes?
Upvotes: 0
Views: 811
Reputation: 1060
You need to do an unmarshal.
from("file:input?noop=true")
.unmarshal().json(JsonLibrary.Jackson, User.class)
Upvotes: 1