Claus Ibsen created CAMEL-25987:
-----------------------------------

             Summary: camel-jsonata - with the default inputType a JSON text 
body is read as one JSON string, and the expression gives an empty result
                 Key: CAMEL-25987
                 URL: https://issues.apache.org/jira/browse/CAMEL-25987
             Project: Camel
          Issue Type: Bug
    Affects Versions: 4.18.0, 4.22.0, 4.23.0
            Reporter: Claus Ibsen
             Fix For: 4.24.0


With the default {{inputType}}, {{Jackson}}, the jsonata producer converts the 
body with {{mapper.convertValue(body, Object.class)}} ({{JsonataEndpoint}}, 
main e6885df7894d, line 152). Only {{inputType=JsonString}} parses JSON text 
(line 148). A JSON text body therefore becomes one JSON string, and a path 
expression on it finds nothing: the result is an empty object or null, with no 
error. A byte[] is refused by JSONata ("Only JSON types (values, Map, List) are 
allowed as input"), and a stream fails in {{convertValue}}.

Checked on 4.24.0-SNAPSHOT with {{camel run}} and the expression 
{{\{"fullName": name\}}}:
* the body {{\{"name": "Camel"\}}} as text, with the default options, gives an 
empty ObjectNode;
* the same text with {{inputType=JsonString&outputType=JsonString}} gives 
{{\{"fullName":"Camel"\}}};
* the same JSON as a Map, with the default options, gives an ObjectNode with 
fullName.

The examples of the component docs sent a JMS text message to the default 
options; they now set inputType and outputType to JsonString (CAMEL-24961).

*Proposed change*: with {{Jackson}}, parse a body that is text, bytes, a stream 
or a file, as {{JsonString}} does, and convert other objects as now.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to