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

Claus Ibsen commented on CAMEL-25330:
-------------------------------------

The hint is not JSON-only: it names the data format from the Content-Type 
header, the file name (json/xml/csv), or the first character of the text ({ or 
[ for json, < for xml): unmarshal: json, unmarshal: jacksonXml (or xpath), 
unmarshal: csv (useMaps: true for a Map per row). When nothing tells, it lists 
the choices: the data format of the payload (json, jacksonXml, csv, ...). PR 
https://github.com/apache/camel/pull/27359

_Claude Code on behalf of davsclaus_

> camel-groovy - a property read on a body that is still text says to unmarshal 
> it first
> --------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25330
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25330
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-groovy
>            Reporter: Claus Ibsen
>            Priority: Minor
>
> A Groovy expression that reads fields of the body, such as {{body.find { 
> it.sku == headers.sku }}}, fails when the body is still the text of the 
> payload (a byte[] or a String holding JSON), because Groovy then iterates the 
> bytes or characters:
> {noformat}groovy.lang.MissingPropertyException: No such property: sku for 
> class: java.lang.Byte (the script variables are exchange, message, body, 
> headers, ...){noformat}
> The hint lists the script variables, which are fine; the cause is that the 
> body was not unmarshalled. Found in the local-model benchmark (round 4, 
> contracts/openapi-server step 1): the model left out the unmarshal (or wrote 
> marshal) before a Groovy lookup, in 2 of 5 runs, and got this message.
> Proposal: when the missing property was looked up on a Byte, Character or 
> String and the message body is a byte[] or a String, the hint says: the body 
> is still text (a byte[]), not parsed data: unmarshal it first (unmarshal: 
> json for JSON) to read its fields.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to