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

   [CAMEL-26324](https://issues.apache.org/jira/browse/CAMEL-26324)
   
   camel-support could convert text to the camel-util-json types `JsonObject` 
and `JsonArray`, but not back. Today a `JsonObject` converted to `String` gives 
the `toString` of a `LinkedHashMap`, `{sku=CAMEL-MUG, qty=3, tags=[a, b]}`, 
which is not JSON, and there is no conversion to `byte[]` or `InputStream`. So 
a `JsonObject` body (from `convertBodyTo: JsonObject`, graphql, 
kubernetes-custom-resources or typesafe-ai) sent to http, a file or a broker 
gives the wrong text or fails.
   
   ## Changes
   
   - `JsonConverter`: `JsonObject` and `JsonArray` to `String`, `byte[]` and 
`InputStream` give their JSON text (`Jsoner`). The bytes use the charset of the 
exchange.
   - A `JsonObject` or `JsonArray` holding a value that is not JSON, such as 
the `GenericKubernetesResource` POJOs of kubernetes-custom-resources, converts 
as before: `String` is the `toString`, and there is no conversion to bytes or a 
stream.
   - Upgrade guide entry for 4.24, because the `String` conversion changes.
   
   This also answers an open question of the payload mode design (CAMEL-25334, 
#28457): the json payload mode can use these converters at the edges.
   
   ## Tests
   
   - `JsonConverterTest`: 8 new tests (object and array to each type, the 
charset, a POJO value, `convertBodyTo` in a route).
   - Run locally: the camel-core converter tests (307), the camel-core type 
converter tests, camel-graphql (34) and camel-typesafe-ai (210), all green.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_0128ThHB3iQdrvSRLVBGRrdP
   


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