This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new a2db2080bcb CAMEL-19828: added missing direct converter (#11929)
a2db2080bcb is described below

commit a2db2080bcbc0d65c13d956062d4b82eafcc9f3e
Author: Otavio Rodolfo Piske <orpi...@users.noreply.github.com>
AuthorDate: Tue Nov 7 17:52:16 2023 +0100

    CAMEL-19828: added missing direct converter (#11929)
    
    Also restore previous behavior for handling JsonNode
---
 .../jackson/converter/JacksonTypeConvertersLoader.java       |  2 ++
 .../component/jackson/converter/JacksonTypeConverters.java   | 12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/converter/JacksonTypeConvertersLoader.java
 
b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/converter/JacksonTypeConvertersLoader.java
index 3e0df6fae52..5f329c36f78 100644
--- 
a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/converter/JacksonTypeConvertersLoader.java
+++ 
b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/converter/JacksonTypeConvertersLoader.java
@@ -62,6 +62,8 @@ public final class JacksonTypeConvertersLoader implements 
TypeConverterLoader, C
             (type, exchange, value) -> 
getJacksonTypeConverters().toReader((com.fasterxml.jackson.databind.JsonNode) 
value, exchange));
         addTypeConverter(registry, java.lang.Boolean.class, 
com.fasterxml.jackson.databind.JsonNode.class, false,
             (type, exchange, value) -> 
getJacksonTypeConverters().toBoolean((com.fasterxml.jackson.databind.JsonNode) 
value, exchange));
+        addTypeConverter(registry, java.lang.Boolean.class, 
com.fasterxml.jackson.databind.node.BooleanNode.class, false,
+            (type, exchange, value) -> 
getJacksonTypeConverters().toBoolean((com.fasterxml.jackson.databind.node.BooleanNode)
 value, exchange));
         addTypeConverter(registry, java.lang.Double.class, 
com.fasterxml.jackson.databind.JsonNode.class, false,
             (type, exchange, value) -> 
getJacksonTypeConverters().toDouble((com.fasterxml.jackson.databind.JsonNode) 
value, exchange));
         addTypeConverter(registry, java.lang.Float.class, 
com.fasterxml.jackson.databind.JsonNode.class, false,
diff --git 
a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/converter/JacksonTypeConverters.java
 
b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/converter/JacksonTypeConverters.java
index 97c8ec0901f..998a2bc7a52 100644
--- 
a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/converter/JacksonTypeConverters.java
+++ 
b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/converter/JacksonTypeConverters.java
@@ -171,10 +171,20 @@ public final class JacksonTypeConverters {
     }
 
     @Converter
-    public Boolean toBoolean(JsonNode node, Exchange exchange) throws 
Exception {
+    public Boolean toBoolean(BooleanNode node, Exchange exchange) throws 
Exception {
         return node.asBoolean();
     }
 
+    @Converter
+    public Boolean toBoolean(JsonNode node, Exchange exchange) throws 
Exception {
+        if (node instanceof BooleanNode) {
+            BooleanNode bn = (BooleanNode) node;
+            return bn.asBoolean();
+        }
+        String text = node.asText();
+        return org.apache.camel.util.ObjectHelper.toBoolean(text);
+    }
+
     @Converter
     public Double toDouble(JsonNode node, Exchange exchange) throws Exception {
         if (node instanceof NumericNode) {

Reply via email to