From 082f9b0ed576da025d6e228159f78b1ea9edc6f1 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 10 May 2021 13:22:44 +0200 Subject: [PATCH 1/2] Extract Field - Actions should not marshal into JSON if the input was not JSON --- extract-field-action.kamelet.yaml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/extract-field-action.kamelet.yaml b/extract-field-action.kamelet.yaml index f685a88e5..cfcbba170 100644 --- a/extract-field-action.kamelet.yaml +++ b/extract-field-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: "field" constant: "{{field}}" - bean: "org.apache.camel.kamelets.utils.transform.ExtractField" - - 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" From 1754970cf94e47485bcb31fa414f8e2959087e21 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Mon, 10 May 2021 13:25:30 +0200 Subject: [PATCH 2/2] Extract Field - Actions should not marshal into JSON if the input was not JSON --- .../extract-field-action.kamelet.yaml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/library/camel-kamelets-catalog/src/main/resources/kamelets/extract-field-action.kamelet.yaml b/library/camel-kamelets-catalog/src/main/resources/kamelets/extract-field-action.kamelet.yaml index f685a88e5..cfcbba170 100644 --- a/library/camel-kamelets-catalog/src/main/resources/kamelets/extract-field-action.kamelet.yaml +++ b/library/camel-kamelets-catalog/src/main/resources/kamelets/extract-field-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: "field" constant: "{{field}}" - bean: "org.apache.camel.kamelets.utils.transform.ExtractField" - - 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"