REST/Jackson: Is it possible to set global PropertyNamingStrategy?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

REST/Jackson: Is it possible to set global PropertyNamingStrategy?

Andreas A.
Usually I use "bindingmode.json" on rest-endpoints and let Camel deal with the marshalling.

Now I would like to control the PropertyNamingStrategy on all marshale/unmarshal. So far my solution is the one below:

ObjectMapper objectMapper = new ObjectMapper();
JacksonDataFormat format = new JacksonDataFormat(objectMapper, MyType.class);
format.getObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE);

restConfiguration().component("servlet");
...
.marshal(format);

This means however I will have to setup a JacksonDataFormat for all my types and explicitly marshal/unmarshal to that dateformat in all routes.

Is there a way to define this strategy globally? I can't figure out where to get hold of the default ObjectMapper and set it on that.

Regards.