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

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

commit 77f10c25fc77c1da3d7aebc75555065862eca799
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Mon May 10 15:23:11 2021 +0200

    Replace Field Action - Actions should not marshal into JSON if the input 
was not JSON
---
 replace-field-action.kamelet.yaml | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/replace-field-action.kamelet.yaml 
b/replace-field-action.kamelet.yaml
index 61fd23e..c6f00b9 100644
--- a/replace-field-action.kamelet.yaml
+++ b/replace-field-action.kamelet.yaml
@@ -44,6 +44,9 @@ spec:
           when:
           - simple: "${header[Content-Type]} == 'application/json'"
             steps:
+            - set-property:
+                name: deserialized
+                constant: "true"
             - unmarshal:
                 json: 
                   library: Jackson
@@ -58,10 +61,14 @@ spec:
           name: "renames"
           constant: "{{renames}}"
       - bean: "org.apache.camel.kamelets.utils.transform.ReplaceField"
-      - marshal:
-          json: 
-            library: Jackson
-            unmarshalTypeName: com.fasterxml.jackson.databind.JsonNode
-      - set-header:
-          name: "Content-Type"
-          constant: "application/json"
+      - choice:
+          when:
+          - simple: "${exchangeProperty[deserialized]} == 'true'"
+            steps:
+            - marshal:
+                json: 
+                  library: Jackson
+                  unmarshalTypeName: com.fasterxml.jackson.databind.JsonNode
+            - set-header:
+                name: "Content-Type"
+                constant: "application/json"

Reply via email to