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

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


The following commit(s) were added to refs/heads/main by this push:
     new bb84c2ff Enhance application-x-struct data type
bb84c2ff is described below

commit bb84c2ffb7ddf60a55cc6811f00b2e746c647d5b
Author: Christoph Deppisch <cdeppi...@redhat.com>
AuthorDate: Fri Sep 15 20:42:41 2023 +0200

    Enhance application-x-struct data type
    
    - Support empty message body value and initialize the application-x-struct 
data type with empty JsonNode {} value
    - Allows follow-up action Kamelets such as insert-field-action to add more 
fields to the empty JsonNode body
---
 .../kamelets/utils/format/converter/json/JsonStructDataType.java     | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/json/JsonStructDataType.java
 
b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/json/JsonStructDataType.java
index 403ab381..948fa704 100644
--- 
a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/json/JsonStructDataType.java
+++ 
b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/json/JsonStructDataType.java
@@ -20,6 +20,7 @@ package org.apache.camel.kamelets.utils.format.converter.json;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import org.apache.camel.CamelExecutionException;
@@ -50,6 +51,10 @@ public class JsonStructDataType extends Transformer {
     }
 
     private InputStream getBodyAsStream(Message message) throws 
InvalidPayloadException {
+        if (message.getBody() == null) {
+            return new 
ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8));
+        }
+
         InputStream bodyStream = message.getBody(InputStream.class);
 
         if (bodyStream == null) {

Reply via email to