davsclaus opened a new pull request, #30475:
URL: https://github.com/apache/camel/pull/30475

   [CAMEL-27270](https://issues.apache.org/jira/browse/CAMEL-27270)
   
   ### The problem
   Since CAMEL-26300 (#29215), `application-json` keeps text that is a Json 
object or array. Any other text becomes a Json string: a Json number, boolean, 
`null`, a quoted string, and also `ORD-1`, which becomes `"ORD-1"`.
   
   That double-encodes a source that gives one Json value as text. 
`google-mail-source` gives the quoted string `"Hello"`, and since CAMEL-27258 
runs its `json` out data type, the consuming route gets `"\"Hello\""`. The 
Kamelet works around it today (apache/camel-kamelets#3296).
   
   ### The change
   In both camel-jackson and camel-jackson3, `JsonDataTypeTransformer` keeps 
text that is exactly one Json value when the `Content-Type` header is 
`application/json`, with or without parameters such as a charset:
   - a quoted string, a number, `true`, `false` or `null` is kept as it is;
   - `FAIL_ON_TRAILING_TOKENS` makes sure the whole text is one value, so `42 
abc` or two strings don't count;
   - without that header, the CAMEL-26300 rule is unchanged;
   - text that isn't Json, such as `ORD-1`, still becomes a Json string with or 
without the header.
   
   The body types description says so, and the catalog copy is regenerated.
   
   This is part of the data types work for the Kamelet catalog 
(apache/camel-kamelets#3117, CAMEL-25928). It unblocks `google-mail-source`, 
`github-commit-source`, `github-event-source` and 
`mongodb-changes-stream-source`.
   
   ### Tests
   - `JsonDataTypeTransformerTest`, in both modules:
     - with `application/json`, `application/json; charset=UTF-8` or 
`APPLICATION/JSON`, the text and bytes `"Hello"`, `42`, `true`, `null` and ` 
"Hello" ` are kept;
     - `ORD-1`, `42 abc`, two quoted strings and empty text still become Json 
strings;
     - with `text/plain`, a quoted string is still encoded again;
     - the CAMEL-26300 tests are unchanged.
   - Run locally: camel-jackson and camel-jackson3, all 121 tests pass.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to