[ 
https://issues.apache.org/jira/browse/CAMEL-17956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17521448#comment-17521448
 ] 

Mikael Andersson Wigander commented on CAMEL-17956:
---------------------------------------------------

BEFORE/AFTER
{code:json}
[
  {
    "adjustedRate"                     : 1.23,
    "collateralQuantityOrNominalAmount": 987.654321,
    "fixedRate"                        : -0.62,
    "floatingRate"                     : 4.56,
    "principalAmountOnMaturityDate"    : 121002700.0,
    "principalAmountOnValueDate"       : -91000000.0,
    "spread"                           : 4.56
  },
  {
    "adjustedRate"                     : 1.23,
    "collateralQuantityOrNominalAmount": 987.654321,
    "fixedRate"                        : -0.62,
    "floatingRate"                     : 4.56,
    "principalAmountOnMaturityDate"    : 1.210027E8,
    "principalAmountOnValueDate"       : -9.1E7,
    "spread"                           : 4.56
  }
]
{code}

> JSONPath option to use global registered ObjectMapper
> -----------------------------------------------------
>
>                 Key: CAMEL-17956
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17956
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jsonpath
>    Affects Versions: 3.14.1, 3.16.0
>            Reporter: Mikael Andersson Wigander
>            Priority: Minor
>
> I have discovered that when using JSONPath in a route, the implementation 
> does not use any ObjectMapper registered, it uses it's own.
> {code:java|title=JacksonMappingProvider.class}
> public class JacksonMappingProvider implements MappingProvider {
> private final ObjectMapper objectMapper;
> public JacksonMappingProvider() {
> this(new ObjectMapper());
> }
> public JacksonMappingProvider(ObjectMapper objectMapper) {
> this.objectMapper = objectMapper;
> }
> {code}
> However, when using *.jsonpathWriteAsString()*, this uses global registered 
> ObjectMapper.
> {code:java|title=JacksonJsonAdapter.class}
> @Override
>     public String writeAsString(Object value, Exchange exchange) {
>         ObjectMapper mapper = 
> resolveObjectMapper(exchange.getContext().getRegistry());
>         try {
>             return mapper.writeValueAsString(value);
>         } catch (Throwable e) {
>             // ignore because we are attempting to convert
>         }
>         return null;
>     }
> {code}
> It does not go through the *JsonPathEngine* so it seems it's a completly 
> differrent implementation however still defined within JSONPath language as 
> in this documentation:
> https://camel.apache.org/components/3.14.x/languages/jsonpath-language.html#_split_json_data_into_sub_rows_as_json



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to