This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch value-to-key-263 in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit 41a5a33570b10a328046286cb97ab5ac8ce811e2 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon May 10 15:13:13 2021 +0200 Value to Key Action - Actions should not marshal into JSON if the input was not JSON --- value-to-key-action.kamelet.yaml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/value-to-key-action.kamelet.yaml b/value-to-key-action.kamelet.yaml index dc64480..ca41ec2 100644 --- a/value-to-key-action.kamelet.yaml +++ b/value-to-key-action.kamelet.yaml @@ -33,6 +33,9 @@ spec: when: - simple: "${header[Content-Type]} == 'application/json'" steps: + - set-property: + name: deserialized + constant: "true" - unmarshal: json: library: Jackson @@ -41,10 +44,14 @@ spec: name: "fields" constant: "{{fields}}" - bean: "org.apache.camel.kamelets.utils.transform.kafka.ValueToKey" - - 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"