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

   [CAMEL-27306](https://issues.apache.org/jira/browse/CAMEL-27306)
   
   ### Problem
   
   With the default `inputType` (`Hydrated`), `JoltEndpoint` parsed JSON text, 
bytes, a stream or a file, and passed any other body to Jolt as it was. A 
Jackson `JsonNode` body reached the transform as an object Jolt does not know, 
because Jolt only works on `Map` and `List` trees. The spec matched nothing and 
the result was `null`, with no error and nothing logged. An array node passed 
through unchanged.
   
   Such a body comes from the `application-x-struct` data type, or from the 
JSON data format with `unmarshalType` set to `JsonNode`, as in the 
`json-deserialize-action` Kamelet. It was found with 
`jolt-transformation-action` after `json-deserialize-action`; 
apache/camel-kamelets#3310 documents a workaround for this.
   
   ### Fix
   
   - A `JsonNode` body is now parsed from its JSON text with Jolt's own 
`JsonUtils`, so the transform gets the same tree as for the same JSON given as 
text, with the same number types. This applies to both input types.
   - Jackson 3 nodes are matched with `instanceof`, since camel-jolt already 
depends on Jackson 3.
   - Jackson 2 nodes are matched by their package 
(`com.fasterxml.jackson.databind.node.`), so Jackson 2 does not become a 
dependency. camel-jsonpath does the same, and a node of either line gives its 
JSON from `toString()`.
   - The component doc and the body type description now list the `JsonNode` 
body. The catalog copies are synced.
   
   ### Tests
   
   `JoltHydratedInputTest` has 5 new tests:
   - an object node and an array node, for both Jackson 3 and Jackson 2;
   - a test that a nested document (with int, long, double, boolean, null, an 
array and an object) gives the same tree as node and as text, with both 
`inputType` values.
   
   Without the fix, all 5 fail: the result is `null` for an object node, and an 
array node comes back unchanged. All 21 camel-jolt tests pass with the fix. 
Jackson 2 `jackson-databind` is added as a test dependency only.
   
   _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