This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch insert-field-261 in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit 47d0cb2365f06eaf8d7b5d67905c20fda1aa5362 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon May 10 16:36:08 2021 +0200 Insert field action - Actions should not marshal into JSON if the input was not JSON --- insert-field-action.kamelet.yaml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/insert-field-action.kamelet.yaml b/insert-field-action.kamelet.yaml index aaf1497..f0b6cca 100644 --- a/insert-field-action.kamelet.yaml +++ b/insert-field-action.kamelet.yaml @@ -38,6 +38,9 @@ spec: when: - simple: "${header[Content-Type]} == 'application/json'" steps: + - set-property: + name: deserialized + constant: "true" - unmarshal: json: library: Jackson @@ -49,10 +52,14 @@ spec: name: "value" constant: "{{value}}" - bean: "org.apache.camel.kamelets.utils.transform.InsertField" - - 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"