You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/05/10 11:26:22 UTC
[camel-kamelets] 01/02: Extract Field - Actions should not marshal
into JSON if the input was not JSON
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch extract-field-261
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit 082f9b0ed576da025d6e228159f78b1ea9edc6f1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon May 10 13:22:44 2021 +0200
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 f685a88..cfcbba1 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"