This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 6c5068c  CAMEL-18768: Add jq function to simple language to make it 
easy to grab some data from JSon message body and use simple for basic JSon 
transformation
6c5068c is described below

commit 6c5068cbe4c512b1a068746207c850665965177f
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 24 09:27:58 2023 +0100

    CAMEL-18768: Add jq function to simple language to make it easy to grab 
some data from JSon message body and use simple for basic JSon transformation
---
 jbang/json-transform/README.adoc  | 52 +++++++++++++++++++++++++++++++++++++++
 jbang/json-transform/beer-jq.yaml | 20 +++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/jbang/json-transform/README.adoc b/jbang/json-transform/README.adoc
new file mode 100644
index 0000000..ee111a7
--- /dev/null
+++ b/jbang/json-transform/README.adoc
@@ -0,0 +1,52 @@
+== JSon Transformation
+
+This example shows a basic JSon transformation using simple and JQ languages.
+
+=== Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+[source,sh]
+----
+$ jbang --version
+----
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+[source,sh]
+----
+$ jbang app install camel@apache/camel
+----
+
+Which allows to run CamelJBang with `camel` as shown below.
+
+=== How to run
+
+Then you can run this example using:
+
+[source,sh]
+----
+$ camel run beer-jq.yaml
+----
+
+Or run with JBang using the longer command line (without installing camel as 
app in JBang):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run beer-jq.yaml
+----
+
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/community/support/[let us know].
+
+We also love contributors, so
+https://camel.apache.org/community/contributing/[get involved] :-)
+
+The Camel riders!
diff --git a/jbang/json-transform/beer-jq.yaml 
b/jbang/json-transform/beer-jq.yaml
new file mode 100644
index 0000000..9563eeb
--- /dev/null
+++ b/jbang/json-transform/beer-jq.yaml
@@ -0,0 +1,20 @@
+- route:
+    nodePrefixId: route-c38
+    id: route-66b0
+    from:
+      uri: kamelet:beer-source
+      id: from-3996
+      steps:
+        - setBody:
+            expression:
+              simple:
+                expression: >-
+                  {
+                    "kind": "${jq(.brand)}",
+                    "beer": "${jq(.name)}"
+                  }
+                id: simple-b320
+            id: setBody-fa01
+        - log:
+            message: ${body}
+            id: log-0c79

Reply via email to