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 13:24:32 UTC
[camel-kamelets] 01/03: Replace Field Action - 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 replace-action-261
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit 682c6655c1d401a21a6a8731c0a31a67e5c37243
Author: Andrea Cosentino <an...@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"