Hmm, not sure if this correct…

When the JsonPathExpression is instantiated an engine is created.
The engine is built out of JsonPathEngine and it assigns a JsonProvider as a 
JacksonJsonProvider.
This provider is defaulting to use its own default ObjectMapper.






/M


------- Original Message -------
On Wednesday, April 27th, 2022 at 18:27, Karen Lease <karenlease...@gmail.com> 
wrote:


> I had a look at the JIRA issue you created for this.
> The JacksonMappingProvider is used only to read the Json, not to write it.
>
> With jsonpathWriteAsString, you'd need to register an ObjectMapper which
> customizes the serialization of the double values. By default, Jackson
> will use the standard Java String representation for a double which uses
> the scientific notation.
>
> When using jsonpath(), the result type in your example is actually a Map
> where the values are Doubles. log("${body}") doesn't use an ObjectMapper
> at all; it just converts the keys and values to a String.
> However you could use a customer processor to format the Doubles as you
> want. For example:
> .jsonpath("$").process(new Processor() {
> public void process(Exchange exchange) {
> Object body = exchange.getIn().getBody();
> if (body instanceof Map) {
> for (Object value : ((Map)body).values()) {
> if (value instanceof Double) {
> String d = String.format("%12.2f", value);
> ...
> Is that helpful?
>
> Karen Lease
>
> On 13/04/2022 06:47, Mikael Andersson Wigander wrote:
>
> > OK, will do that.
> >
> > However if I use jsonpathWriteAsString then it uses a global Objectmapper 
> > but still my problem exists with the numerics, but that is maybe another 
> > issue !?
> >
> >
> > /M
> >
> > ------- Original Message -------
> > On Wednesday, April 13th, 2022 at 06:44, Claus Ibsen claus.ib...@gmail.com 
> > wrote:
> >
> > > Hi
> > >
> > > Ah okay that sounds like a good improvement. You are welcome to create a 
> > > JIRA.
> > >
> > > On Wed, Apr 13, 2022 at 6:35 AM Mikael Andersson Wigander
> > > mikael.andersson.wigan...@pm.me.invalid wrote:
> > >
> > > > Hi
> > > >
> > > > I have discovered that when using JSONPath in a route, the 
> > > > implementation does not use any ObjectMapper registered, it uses it's 
> > > > own.
> > > >
> > > > --------------------------------------------
> > > > JacksonMappingProvider.class
> > > >
> > > > public class JacksonMappingProvider implements MappingProvider {
> > > >
> > > > private final ObjectMapper objectMapper;
> > > >
> > > > public JacksonMappingProvider() {
> > > > this(new ObjectMapper());
> > > > }
> > > >
> > > > public JacksonMappingProvider(ObjectMapper objectMapper) {
> > > > this.objectMapper = objectMapper;
> > > > }
> > > > ----------------------------------------------
> > > >
> > > > Is this the intended solution or should we make JSONPath use any 
> > > > globally registered mapper as an option?
> > > >
> > > > I have an issue when using JSONPath and my values are numerics and 
> > > > large decimal format like 123.456789. They get parsed as Double and 
> > > > then when representing the json string they are in scientific notation.
> > > > The use of Jackson Features are not available.
> > > >
> > > > When using json as Dataformat we can register a global Objectmapper and 
> > > > use that but when using JSONPath it is not implemented.
> > > >
> > > > My Camel version is 3.14.1
> > > >
> > > > /M
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > http://davsclaus.com @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to