You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/02/04 06:57:00 UTC
[jira] [Commented] (CAMEL-16139) Support in Json for GlobalOption
override of autoDiscoverObjectMapper
[ https://issues.apache.org/jira/browse/CAMEL-16139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17278594#comment-17278594 ]
Claus Ibsen commented on CAMEL-16139:
-------------------------------------
You can use DataFormatCustomizer
> Support in Json for GlobalOption override of autoDiscoverObjectMapper
> ---------------------------------------------------------------------
>
> Key: CAMEL-16139
> URL: https://issues.apache.org/jira/browse/CAMEL-16139
> Project: Camel
> Issue Type: New Feature
> Components: camel-jackson
> Affects Versions: 3.7.1
> Environment: Camel 3.7+
> Reporter: Bob Paulin
> Priority: Minor
>
> The Java DSL offers a simple way to get started marshalling and unmarshaling objects mid route by:
>
> {code:java}
> .unmarshal().json(JsonLibrary.Jackson, Map.class){code}
>
> In 3.x an option was added to allow Jackson to automatically discover ObjectMappers in the Camel registry:
> autoDiscoverObjectMapper
>
> This is very convenient to apply global Object mapper configurations to an entire application. However it's defaulted to false and there does not appear to be a way to set this option in the Java DSL without replacing the above code with a DataFormat Object
> EX
> {code:java}
> JacksonDataFormat format = new JacksonDataFormat(Map.class);
> format.setAutoDiscoverObjectMapper(true);
> .unmarshal(format);{code}
> This is a big change to make all over the project.
> I'd like to propose being able to set this option globally in the camel context with the GlobalOptions
> EX
> {code:java}
> getContext().getGlobalOptions().put("jackson.json.autoDiscoverObjectMapper", "true");{code}
> Then use the Java DSL as is to a ObjectMapper that is already bound in the registry. Would this be an acceptable approach? Other options I'm missing.
>
> I have a patch with a suggested implementation.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)