Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16061

JSLT-Component: Object-Mapper changes large Decimal-Numbers (to scientific notation)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.7.0
    • 3.8.0
    • None
    • None
    • Unknown

    Description

      Hi there,

      When using the JSLT-Component, large Decimal-Numbers seem to be represented in scientific notation and rounded (probably double). This changes the value itself, which is a big no no in my use cases.
      Example:

      in=> 11321321.12 : out => 1.132132112E7 (scientific)
      in=> 321321321.123657891234 : out => 3.213213211236579E8 (scientific and rounded)

      ObjectMapper (Jackson) is instantiated without config, which causes actually trouble with Decimal-Numbers as far as I know.

      Dealing with BigDecimal needs to be configured in Jackson. Since the ObjectMapper is instantiated in the Component itself, it's hard to get the Mapper-Instance.

       

      <org.apache.camel.component.jslt.JsltEndpoint.onExchange(Exchange exchange):138> (decompiled source)
      protected void onExchange(Exchange exchange) throws Exception {
      .....................
      ObjectMapper objectMapper = new ObjectMapper();
      JsonNode input;
      if (exchange.getIn().getBody() instanceof String) {
      input = objectMapper.readTree((String)exchange.getIn().getBody(String.class));
      }
      ......................

        

      cibsen@e-ma.net suggested following change:

      "We can surely look at making this configurable, and also maybe some simple option you can turn on|off to affect the object mapper - so you dont need to configure a custom instance. So maybe its 2 things, 1 simple option to set true|false, and 2 to setup a custom ObjectMapper."

       

      Attachments

        Activity

          People

            acosentino Andrea Cosentino
            webnic Nicolas Weber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: