Json Serialize Action
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Turns a body of parsed data, such as a Map, a List or parsed JSON, into JSON text.
Use it to send parsed data to a sink that needs JSON text, for example after jsonata-action or json-deserialize-action, whose output is parsed JSON. To do the opposite, use json-deserialize-action.
Input: parsed data: a Map, a List, or parsed JSON (a Jackson JsonNode).
Output: the body is JSON text, as bytes. The Content-Type header is set to application/json.
Good to know: a body that is already JSON text is kept as it is, not quoted: text, bytes or a stream that start with { and end with }, or start with [ and end with ], such as {"id":1}. It is not checked to be valid JSON. Any other text becomes one JSON string, in quotes: hello becomes "hello", and the text 42 becomes "42". Bytes or a stream that hold another JSON value, such as 42, are kept as well; other bytes become one JSON string too.
Dependencies
At runtime, the json-serialize-action Kamelet relies upon the presence of the following dependencies:
-
camel:kamelet
-
camel:jackson3
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:json-serialize-action"
parameters:
.
.
.
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml