davsclaus commented on code in PR #30476:
URL: https://github.com/apache/camel/pull/30476#discussion_r4640138389
##########
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/transform/JsonDataTypeTransformer.java:
##########
@@ -68,10 +75,12 @@ public void transform(Message message, DataType fromType,
DataType toType) {
// a Map or a List has no class to write it as: it becomes a
Json object or array
marshalled = Json.mapper().writeValueAsBytes(body);
} else if (!hasContentClass && isText(body)) {
- // read as text with the exchange charset: a Json object or
array is kept, and any other text, also a
- // Json number, boolean, null or quoted string, becomes a Json
string
+ // read as text with the exchange charset: a Json object or
array is kept, and so is a Json number,
+ // boolean, null or quoted string when the Content-Type says
the text is Json; any other text becomes a
+ // Json string
String text = message.getMandatoryBody(String.class);
- marshalled = Json.isJson(text) ?
text.getBytes(StandardCharsets.UTF_8) : Json.mapper().writeValueAsBytes(text);
+ marshalled = (Json.isJson(text) || isJsonContent(message) &&
isJsonValue(text))
Review Comment:
Done in 6d5442d0, in both camel-jackson and camel-jackson3.
_Claude Code on behalf of Claus Ibsen_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]