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.git


The following commit(s) were added to refs/heads/main by this push:
     new 6cfe832feed0 CAMEL-23053: Add toJson functions to Simple language
6cfe832feed0 is described below

commit 6cfe832feed03f433e5b69af1defc2a6fd43c09b
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Mar 8 10:46:49 2026 +0100

    CAMEL-23053: Add toJson functions to Simple language
---
 .../org/apache/camel/catalog/languages/simple.json | 84 +++++++++++-----------
 .../org/apache/camel/language/simple/simple.json   | 84 +++++++++++-----------
 .../modules/languages/pages/simple-language.adoc   | 17 +++++
 .../camel/language/csimple/CSimpleHelper.java      |  8 ++-
 .../camel/language/simple/SimpleConstants.java     |  8 +++
 .../simple/ast/SimpleFunctionExpression.java       | 21 +++++-
 .../apache/camel/language/simple/SimpleTest.java   | 14 ++++
 .../camel/support/builder/ExpressionBuilder.java   | 36 +++-------
 .../java/org/apache/camel/util/SimpleUtils.java    |  2 +
 9 files changed, 161 insertions(+), 113 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
index e7bad8152e84..4538f96b4bc6 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
@@ -102,46 +102,48 @@
     "pad(exp,width,separator)": { "index": 74, "kind": "function", 
"displayName": "Pad String", "group": "string", "label": "string", "required": 
false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Pads the expression with extra padding if necessary, according the the total 
width. The separator is by default a space. If the width is negative then 
padding to the right, otherwise to the left.", "ognl" [...]
     "pretty(exp)": { "index": 75, "kind": "function", "displayName": "Pretty 
Print", "group": "xml", "label": "json,xml", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
a String, and attempts to pretty print if JSon or XML, otherwise the expression 
is returned as the String value.", "ognl": false, "suffix": "}" },
     "prettyBody": { "index": 76, "kind": "function", "displayName": "Pretty 
Body", "group": "xml", "label": "json,xml", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the body to a 
String, and attempts to pretty print if JSon or XML; otherwise the body is 
returned as the String value.", "ognl": false, "suffix": "}" },
-    "toJson(exp)": { "index": 77, "kind": "function", "displayName": "To 
JSon", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
JSon String representation.", "ognl": false, "suffix": "}" },
-    "toJsonBody": { "index": 78, "kind": "function", "displayName": "To JSon 
Body", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the body to JSon 
String representation.", "ognl": false, "suffix": "}" },
-    "properties:key:default": { "index": 79, "kind": "function", 
"displayName": "Property Placeholder", "group": "core", "label": "core", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Lookup a property placeholder with the given key. If the key does not exist 
nor has a value, then an optional default value can be specified.", "ognl": 
false, "suffix": "}" },
-    "propertiesExist:key": { "index": 80, "kind": "function", "displayName": 
"Property Placeholder Exists", "group": "core", "label": "core", "required": 
false, "javaType": "boolean", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Checks whether a property placeholder with the given key exists or not. The 
result can be negated by prefixing the key with !", "ognl": false, "suffix": 
"}" },
-    "quote(exp)": { "index": 81, "kind": "function", "displayName": "Quote", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the message body (or expression) as a 
double quoted string", "ognl": false, "suffix": "}" },
-    "random(min,max)": { "index": 82, "kind": "function", "displayName": 
"Random", "group": "number", "label": "number", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns a random number between min and 
max (exclusive)", "ognl": false, "suffix": "}" },
-    "range(min,max)": { "index": 83, "kind": "function", "displayName": 
"Range", "group": "number", "label": "number", "required": false, "javaType": 
"List", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a list of 
increasing integers between the given interval (exclusive)", "ognl": false, 
"suffix": "}" },
-    "ref:name": { "index": 84, "kind": "function", "displayName": "Bean By 
Id", "group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "To look up a bean from the Registry with the 
given name.", "ognl": false, "suffix": "}" },
-    "replace(from,to,exp)": { "index": 85, "kind": "function", "displayName": 
"Replace String Values", "group": "string", "label": "string", "required": 
false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Replace all the string values in the message body\/expression. To make it 
easier to replace single and double quotes, then you can use XML escaped values 
`\\&quot;` as double quote, `\\&apos;` as s [...]
-    "reverse(val...)": { "index": 86, "kind": "function", "displayName": 
"Reverse Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values, but in reverse order", "ognl": false, 
"suffix": "}" },
-    "routeGroup": { "index": 87, "kind": "function", "displayName": "Route 
Group", "group": "core", "label": "core", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The route group of the 
current route the Exchange is being routed. Not all routes have a group 
assigned, so this may be null.", "ognl": false, "suffix": "}" },
-    "routeId": { "index": 88, "kind": "function", "displayName": "Route Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The route id of the current route the Exchange 
is being routed", "ognl": false, "suffix": "}" },
-    "safeQuote(exp)": { "index": 89, "kind": "function", "displayName": "Safe 
Quote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) safely quoted if needed", "ognl": false, "suffix": "}" },
-    "setVariable(key,exp)": { "index": 90, "kind": "function", "displayName": 
"Set Variable", "group": "attachment", "label": "attachment", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets an attachment with payload from the message body\/expression.", "ognl": 
false, "suffix": "}" },
-    "setHeader(name,type,exp)": { "index": 91, "kind": "function", 
"displayName": "Set Header", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a message header with the given expression (optional converting to the 
given type)", "ognl": false, "suffix": "}" },
-    "setVariable(name,type,exp)": { "index": 92, "kind": "function", 
"displayName": "Set Variable", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a variable with the given expression (optional converting to the given 
type)", "ognl": false, "suffix": "}" },
-    "shuffle(val...)": { "index": 93, "kind": "function", "displayName": 
"Shuffle Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values shuffled in random order", "ognl": false, 
"suffix": "}" },
-    "size(exp)": { "index": 94, "kind": "function", "displayName": "Size", 
"group": "collection", "label": "collection", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns the number of elements in 
collection or array based payloads. If the value is null then 0 is returned, 
otherwise 1.", "ognl": false, "suffix": "}" },
-    "skip(num)": { "index": 95, "kind": "function", "displayName": "Skip First 
Items from the Message Body", "group": "collection", "label": "collection", 
"required": false, "javaType": "java.util.Iterator", "prefix": "${", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The skip function iterates the message body and skips 
the first number of items. This can be used with the Splitter EIP to split a 
message body and skip the first N number [...]
-    "split(exp,separator)": { "index": 96, "kind": "function", "displayName": 
"Split String Values", "group": "collection", "label": "collection", 
"required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Splits the message body\/expression as a String value using the separator into 
a String array", "ognl": false, "suffix": "}" },
-    "stepId": { "index": 97, "kind": "function", "displayName": "Step Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current step the 
Exchange is being routed.", "ognl": false, "suffix": "}" },
-    "substring(head,tail)": { "index": 98, "kind": "function", "displayName": 
"Substring", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Returns a substring of 
the message body\/expression. If only one positive number, then the returned 
string is clipped from the beginning. If only one negative number, then the 
returned string is clipped from t [...]
-    "substringAfter(exp,before)": { "index": 99, "kind": "function", 
"displayName": "Substring After", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes after. Returns 
null if nothing comes after.", "ognl": false, "suffix": "}" },
-    "substringBefore(exp,before)": { "index": 100, "kind": "function", 
"displayName": "Substring Before", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes before. Returns 
null if nothing comes before.", "ognl": false, "suffix": "}" },
-    "substringBetween(exp,after,before)": { "index": 101, "kind": "function", 
"displayName": "Substring Between", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that are between after and 
before. Returns null if nothing comes between.", "ognl": false, "suffix": "}" },
-    "sum(val...)": { "index": 102, "kind": "function", "displayName": 
"Calculate Sum Number", "group": "number", "label": "number", "required": 
false, "javaType": "long", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sums together all the values as integral numbers. This function can also be 
used to subtract by using negative numbers.", "ognl": false, "suffix": "}" },
-    "sys.name": { "index": 103, "kind": "function", "displayName": "JVM System 
Property", "group": "other", "label": "other", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The JVM system property 
with the given name", "ognl": false, "suffix": "}" },
-    "threadId": { "index": 104, "kind": "function", "displayName": "Thread 
Id", "group": "other", "label": "other", "required": false, "javaType": "long", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current thread. Can be 
used for logging.", "ognl": false, "suffix": "}" },
-    "threadName": { "index": 105, "kind": "function", "displayName": "Thread 
Name", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the name of the 
current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
-    "throwException(type,msg)": { "index": 106, "kind": "function", 
"displayName": "Throw Exception", "group": "core", "label": "core", "required": 
false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Deliberately throws an error. Uses IllegalArgumentException by default if no 
type is specified (use fully qualified classname).", "ognl": false, "suffix": 
"}" },
-    "trim(exp)": { "index": 107, "kind": "function", "displayName": "Trim", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The trim function trims the message body (or 
expression) by removing all leading and trailing white spaces.", "ognl": false, 
"suffix": "}" },
-    "type:name.field": { "index": 108, "kind": "function", "displayName": 
"Java Field Value", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "To refer to a type or 
field by its classname. To refer to a field, you can append .FIELD_NAME. For 
example, you can refer to the constant field from Exchange as: 
`org.apache.camel.Exchange.FILE_NAME`", "ognl":  [...]
-    "kindOfType(exp)": { "index": 109, "kind": "function", "displayName": 
"Kind of Type", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "What kind of type is 
the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": 
"}" },
-    "unquote(exp)": { "index": 110, "kind": "function", "displayName": 
"Unquote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) with any leading\/ending quotes removed", "ognl": false, 
"suffix": "}" },
-    "uppercase(exp)": { "index": 111, "kind": "function", "displayName": 
"Uppercase", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Uppercases the message 
body (or expression)", "ognl": false, "suffix": "}" },
-    "uuid(type)": { "index": 112, "kind": "function", "displayName": "Generate 
UUID", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a UUID using the 
Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and 
`simple` as the type. If no type is given, the default is used. It is also 
possible to use a custom `UuidGenera [...]
-    "val(exp)": { "index": 113, "kind": "function", "displayName": "Value", 
"group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the expression as a constant value", 
"ognl": false, "suffix": "}" },
-    "variable.name": { "index": 114, "kind": "function", "displayName": 
"Variable", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The variable with the 
given name", "ognl": true, "suffix": "}" },
-    "variableAs(key,type)": { "index": 115, "kind": "function", "displayName": 
"Variable As", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the variable to 
the given type (classname).", "ognl": false, "suffix": "}" },
-    "variables": { "index": 116, "kind": "function", "displayName": 
"Variables", "group": "core", "label": "core", "required": false, "javaType": 
"java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns all the variables 
from the current Exchange in a Map", "ognl": false, "suffix": "}" },
-    "xpath(input,exp)": { "index": 117, "kind": "function", "displayName": 
"XPath", "group": "xml", "label": "xml", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "When working with XML 
data, then this allows using the XPath language, for example, to extract data 
from the message body (in XML format). This requires having camel-xpath JAR on 
the classpath. For input (optional), you ca [...]
+    "toPrettyJson(exp)": { "index": 77, "kind": "function", "displayName": "To 
Pretty JSon", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
JSon String representation.", "ognl": false, "suffix": "}" },
+    "toPrettyJsonBody": { "index": 78, "kind": "function", "displayName": "To 
Pretty JSon Body", "group": "json", "label": "json", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Converts the body to 
JSon String representation.", "ognl": false, "suffix": "}" },
+    "toJson(exp)": { "index": 79, "kind": "function", "displayName": "To 
JSon", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
JSon String representation.", "ognl": false, "suffix": "}" },
+    "toJsonBody": { "index": 80, "kind": "function", "displayName": "To JSon 
Body", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the body to JSon 
String representation.", "ognl": false, "suffix": "}" },
+    "properties:key:default": { "index": 81, "kind": "function", 
"displayName": "Property Placeholder", "group": "core", "label": "core", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Lookup a property placeholder with the given key. If the key does not exist 
nor has a value, then an optional default value can be specified.", "ognl": 
false, "suffix": "}" },
+    "propertiesExist:key": { "index": 82, "kind": "function", "displayName": 
"Property Placeholder Exists", "group": "core", "label": "core", "required": 
false, "javaType": "boolean", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Checks whether a property placeholder with the given key exists or not. The 
result can be negated by prefixing the key with !", "ognl": false, "suffix": 
"}" },
+    "quote(exp)": { "index": 83, "kind": "function", "displayName": "Quote", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the message body (or expression) as a 
double quoted string", "ognl": false, "suffix": "}" },
+    "random(min,max)": { "index": 84, "kind": "function", "displayName": 
"Random", "group": "number", "label": "number", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns a random number between min and 
max (exclusive)", "ognl": false, "suffix": "}" },
+    "range(min,max)": { "index": 85, "kind": "function", "displayName": 
"Range", "group": "number", "label": "number", "required": false, "javaType": 
"List", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a list of 
increasing integers between the given interval (exclusive)", "ognl": false, 
"suffix": "}" },
+    "ref:name": { "index": 86, "kind": "function", "displayName": "Bean By 
Id", "group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "To look up a bean from the Registry with the 
given name.", "ognl": false, "suffix": "}" },
+    "replace(from,to,exp)": { "index": 87, "kind": "function", "displayName": 
"Replace String Values", "group": "string", "label": "string", "required": 
false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Replace all the string values in the message body\/expression. To make it 
easier to replace single and double quotes, then you can use XML escaped values 
`\\&quot;` as double quote, `\\&apos;` as s [...]
+    "reverse(val...)": { "index": 88, "kind": "function", "displayName": 
"Reverse Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values, but in reverse order", "ognl": false, 
"suffix": "}" },
+    "routeGroup": { "index": 89, "kind": "function", "displayName": "Route 
Group", "group": "core", "label": "core", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The route group of the 
current route the Exchange is being routed. Not all routes have a group 
assigned, so this may be null.", "ognl": false, "suffix": "}" },
+    "routeId": { "index": 90, "kind": "function", "displayName": "Route Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The route id of the current route the Exchange 
is being routed", "ognl": false, "suffix": "}" },
+    "safeQuote(exp)": { "index": 91, "kind": "function", "displayName": "Safe 
Quote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) safely quoted if needed", "ognl": false, "suffix": "}" },
+    "setVariable(key,exp)": { "index": 92, "kind": "function", "displayName": 
"Set Variable", "group": "attachment", "label": "attachment", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets an attachment with payload from the message body\/expression.", "ognl": 
false, "suffix": "}" },
+    "setHeader(name,type,exp)": { "index": 93, "kind": "function", 
"displayName": "Set Header", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a message header with the given expression (optional converting to the 
given type)", "ognl": false, "suffix": "}" },
+    "setVariable(name,type,exp)": { "index": 94, "kind": "function", 
"displayName": "Set Variable", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a variable with the given expression (optional converting to the given 
type)", "ognl": false, "suffix": "}" },
+    "shuffle(val...)": { "index": 95, "kind": "function", "displayName": 
"Shuffle Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values shuffled in random order", "ognl": false, 
"suffix": "}" },
+    "size(exp)": { "index": 96, "kind": "function", "displayName": "Size", 
"group": "collection", "label": "collection", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns the number of elements in 
collection or array based payloads. If the value is null then 0 is returned, 
otherwise 1.", "ognl": false, "suffix": "}" },
+    "skip(num)": { "index": 97, "kind": "function", "displayName": "Skip First 
Items from the Message Body", "group": "collection", "label": "collection", 
"required": false, "javaType": "java.util.Iterator", "prefix": "${", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The skip function iterates the message body and skips 
the first number of items. This can be used with the Splitter EIP to split a 
message body and skip the first N number [...]
+    "split(exp,separator)": { "index": 98, "kind": "function", "displayName": 
"Split String Values", "group": "collection", "label": "collection", 
"required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Splits the message body\/expression as a String value using the separator into 
a String array", "ognl": false, "suffix": "}" },
+    "stepId": { "index": 99, "kind": "function", "displayName": "Step Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current step the 
Exchange is being routed.", "ognl": false, "suffix": "}" },
+    "substring(head,tail)": { "index": 100, "kind": "function", "displayName": 
"Substring", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Returns a substring of 
the message body\/expression. If only one positive number, then the returned 
string is clipped from the beginning. If only one negative number, then the 
returned string is clipped from  [...]
+    "substringAfter(exp,before)": { "index": 101, "kind": "function", 
"displayName": "Substring After", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes after. Returns 
null if nothing comes after.", "ognl": false, "suffix": "}" },
+    "substringBefore(exp,before)": { "index": 102, "kind": "function", 
"displayName": "Substring Before", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes before. Returns 
null if nothing comes before.", "ognl": false, "suffix": "}" },
+    "substringBetween(exp,after,before)": { "index": 103, "kind": "function", 
"displayName": "Substring Between", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that are between after and 
before. Returns null if nothing comes between.", "ognl": false, "suffix": "}" },
+    "sum(val...)": { "index": 104, "kind": "function", "displayName": 
"Calculate Sum Number", "group": "number", "label": "number", "required": 
false, "javaType": "long", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sums together all the values as integral numbers. This function can also be 
used to subtract by using negative numbers.", "ognl": false, "suffix": "}" },
+    "sys.name": { "index": 105, "kind": "function", "displayName": "JVM System 
Property", "group": "other", "label": "other", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The JVM system property 
with the given name", "ognl": false, "suffix": "}" },
+    "threadId": { "index": 106, "kind": "function", "displayName": "Thread 
Id", "group": "other", "label": "other", "required": false, "javaType": "long", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current thread. Can be 
used for logging.", "ognl": false, "suffix": "}" },
+    "threadName": { "index": 107, "kind": "function", "displayName": "Thread 
Name", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the name of the 
current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
+    "throwException(type,msg)": { "index": 108, "kind": "function", 
"displayName": "Throw Exception", "group": "core", "label": "core", "required": 
false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Deliberately throws an error. Uses IllegalArgumentException by default if no 
type is specified (use fully qualified classname).", "ognl": false, "suffix": 
"}" },
+    "trim(exp)": { "index": 109, "kind": "function", "displayName": "Trim", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The trim function trims the message body (or 
expression) by removing all leading and trailing white spaces.", "ognl": false, 
"suffix": "}" },
+    "type:name.field": { "index": 110, "kind": "function", "displayName": 
"Java Field Value", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "To refer to a type or 
field by its classname. To refer to a field, you can append .FIELD_NAME. For 
example, you can refer to the constant field from Exchange as: 
`org.apache.camel.Exchange.FILE_NAME`", "ognl":  [...]
+    "kindOfType(exp)": { "index": 111, "kind": "function", "displayName": 
"Kind of Type", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "What kind of type is 
the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": 
"}" },
+    "unquote(exp)": { "index": 112, "kind": "function", "displayName": 
"Unquote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) with any leading\/ending quotes removed", "ognl": false, 
"suffix": "}" },
+    "uppercase(exp)": { "index": 113, "kind": "function", "displayName": 
"Uppercase", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Uppercases the message 
body (or expression)", "ognl": false, "suffix": "}" },
+    "uuid(type)": { "index": 114, "kind": "function", "displayName": "Generate 
UUID", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a UUID using the 
Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and 
`simple` as the type. If no type is given, the default is used. It is also 
possible to use a custom `UuidGenera [...]
+    "val(exp)": { "index": 115, "kind": "function", "displayName": "Value", 
"group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the expression as a constant value", 
"ognl": false, "suffix": "}" },
+    "variable.name": { "index": 116, "kind": "function", "displayName": 
"Variable", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The variable with the 
given name", "ognl": true, "suffix": "}" },
+    "variableAs(key,type)": { "index": 117, "kind": "function", "displayName": 
"Variable As", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the variable to 
the given type (classname).", "ognl": false, "suffix": "}" },
+    "variables": { "index": 118, "kind": "function", "displayName": 
"Variables", "group": "core", "label": "core", "required": false, "javaType": 
"java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns all the variables 
from the current Exchange in a Map", "ognl": false, "suffix": "}" },
+    "xpath(input,exp)": { "index": 119, "kind": "function", "displayName": 
"XPath", "group": "xml", "label": "xml", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "When working with XML 
data, then this allows using the XPath language, for example, to extract data 
from the message body (in XML format). This requires having camel-xpath JAR on 
the classpath. For input (optional), you ca [...]
   }
 }
diff --git 
a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
 
b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
index e7bad8152e84..4538f96b4bc6 100644
--- 
a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
+++ 
b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
@@ -102,46 +102,48 @@
     "pad(exp,width,separator)": { "index": 74, "kind": "function", 
"displayName": "Pad String", "group": "string", "label": "string", "required": 
false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Pads the expression with extra padding if necessary, according the the total 
width. The separator is by default a space. If the width is negative then 
padding to the right, otherwise to the left.", "ognl" [...]
     "pretty(exp)": { "index": 75, "kind": "function", "displayName": "Pretty 
Print", "group": "xml", "label": "json,xml", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
a String, and attempts to pretty print if JSon or XML, otherwise the expression 
is returned as the String value.", "ognl": false, "suffix": "}" },
     "prettyBody": { "index": 76, "kind": "function", "displayName": "Pretty 
Body", "group": "xml", "label": "json,xml", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the body to a 
String, and attempts to pretty print if JSon or XML; otherwise the body is 
returned as the String value.", "ognl": false, "suffix": "}" },
-    "toJson(exp)": { "index": 77, "kind": "function", "displayName": "To 
JSon", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
JSon String representation.", "ognl": false, "suffix": "}" },
-    "toJsonBody": { "index": 78, "kind": "function", "displayName": "To JSon 
Body", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the body to JSon 
String representation.", "ognl": false, "suffix": "}" },
-    "properties:key:default": { "index": 79, "kind": "function", 
"displayName": "Property Placeholder", "group": "core", "label": "core", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Lookup a property placeholder with the given key. If the key does not exist 
nor has a value, then an optional default value can be specified.", "ognl": 
false, "suffix": "}" },
-    "propertiesExist:key": { "index": 80, "kind": "function", "displayName": 
"Property Placeholder Exists", "group": "core", "label": "core", "required": 
false, "javaType": "boolean", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Checks whether a property placeholder with the given key exists or not. The 
result can be negated by prefixing the key with !", "ognl": false, "suffix": 
"}" },
-    "quote(exp)": { "index": 81, "kind": "function", "displayName": "Quote", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the message body (or expression) as a 
double quoted string", "ognl": false, "suffix": "}" },
-    "random(min,max)": { "index": 82, "kind": "function", "displayName": 
"Random", "group": "number", "label": "number", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns a random number between min and 
max (exclusive)", "ognl": false, "suffix": "}" },
-    "range(min,max)": { "index": 83, "kind": "function", "displayName": 
"Range", "group": "number", "label": "number", "required": false, "javaType": 
"List", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a list of 
increasing integers between the given interval (exclusive)", "ognl": false, 
"suffix": "}" },
-    "ref:name": { "index": 84, "kind": "function", "displayName": "Bean By 
Id", "group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "To look up a bean from the Registry with the 
given name.", "ognl": false, "suffix": "}" },
-    "replace(from,to,exp)": { "index": 85, "kind": "function", "displayName": 
"Replace String Values", "group": "string", "label": "string", "required": 
false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Replace all the string values in the message body\/expression. To make it 
easier to replace single and double quotes, then you can use XML escaped values 
`\\&quot;` as double quote, `\\&apos;` as s [...]
-    "reverse(val...)": { "index": 86, "kind": "function", "displayName": 
"Reverse Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values, but in reverse order", "ognl": false, 
"suffix": "}" },
-    "routeGroup": { "index": 87, "kind": "function", "displayName": "Route 
Group", "group": "core", "label": "core", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The route group of the 
current route the Exchange is being routed. Not all routes have a group 
assigned, so this may be null.", "ognl": false, "suffix": "}" },
-    "routeId": { "index": 88, "kind": "function", "displayName": "Route Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The route id of the current route the Exchange 
is being routed", "ognl": false, "suffix": "}" },
-    "safeQuote(exp)": { "index": 89, "kind": "function", "displayName": "Safe 
Quote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) safely quoted if needed", "ognl": false, "suffix": "}" },
-    "setVariable(key,exp)": { "index": 90, "kind": "function", "displayName": 
"Set Variable", "group": "attachment", "label": "attachment", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets an attachment with payload from the message body\/expression.", "ognl": 
false, "suffix": "}" },
-    "setHeader(name,type,exp)": { "index": 91, "kind": "function", 
"displayName": "Set Header", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a message header with the given expression (optional converting to the 
given type)", "ognl": false, "suffix": "}" },
-    "setVariable(name,type,exp)": { "index": 92, "kind": "function", 
"displayName": "Set Variable", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a variable with the given expression (optional converting to the given 
type)", "ognl": false, "suffix": "}" },
-    "shuffle(val...)": { "index": 93, "kind": "function", "displayName": 
"Shuffle Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values shuffled in random order", "ognl": false, 
"suffix": "}" },
-    "size(exp)": { "index": 94, "kind": "function", "displayName": "Size", 
"group": "collection", "label": "collection", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns the number of elements in 
collection or array based payloads. If the value is null then 0 is returned, 
otherwise 1.", "ognl": false, "suffix": "}" },
-    "skip(num)": { "index": 95, "kind": "function", "displayName": "Skip First 
Items from the Message Body", "group": "collection", "label": "collection", 
"required": false, "javaType": "java.util.Iterator", "prefix": "${", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The skip function iterates the message body and skips 
the first number of items. This can be used with the Splitter EIP to split a 
message body and skip the first N number [...]
-    "split(exp,separator)": { "index": 96, "kind": "function", "displayName": 
"Split String Values", "group": "collection", "label": "collection", 
"required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Splits the message body\/expression as a String value using the separator into 
a String array", "ognl": false, "suffix": "}" },
-    "stepId": { "index": 97, "kind": "function", "displayName": "Step Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current step the 
Exchange is being routed.", "ognl": false, "suffix": "}" },
-    "substring(head,tail)": { "index": 98, "kind": "function", "displayName": 
"Substring", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Returns a substring of 
the message body\/expression. If only one positive number, then the returned 
string is clipped from the beginning. If only one negative number, then the 
returned string is clipped from t [...]
-    "substringAfter(exp,before)": { "index": 99, "kind": "function", 
"displayName": "Substring After", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes after. Returns 
null if nothing comes after.", "ognl": false, "suffix": "}" },
-    "substringBefore(exp,before)": { "index": 100, "kind": "function", 
"displayName": "Substring Before", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes before. Returns 
null if nothing comes before.", "ognl": false, "suffix": "}" },
-    "substringBetween(exp,after,before)": { "index": 101, "kind": "function", 
"displayName": "Substring Between", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that are between after and 
before. Returns null if nothing comes between.", "ognl": false, "suffix": "}" },
-    "sum(val...)": { "index": 102, "kind": "function", "displayName": 
"Calculate Sum Number", "group": "number", "label": "number", "required": 
false, "javaType": "long", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sums together all the values as integral numbers. This function can also be 
used to subtract by using negative numbers.", "ognl": false, "suffix": "}" },
-    "sys.name": { "index": 103, "kind": "function", "displayName": "JVM System 
Property", "group": "other", "label": "other", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The JVM system property 
with the given name", "ognl": false, "suffix": "}" },
-    "threadId": { "index": 104, "kind": "function", "displayName": "Thread 
Id", "group": "other", "label": "other", "required": false, "javaType": "long", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current thread. Can be 
used for logging.", "ognl": false, "suffix": "}" },
-    "threadName": { "index": 105, "kind": "function", "displayName": "Thread 
Name", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the name of the 
current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
-    "throwException(type,msg)": { "index": 106, "kind": "function", 
"displayName": "Throw Exception", "group": "core", "label": "core", "required": 
false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Deliberately throws an error. Uses IllegalArgumentException by default if no 
type is specified (use fully qualified classname).", "ognl": false, "suffix": 
"}" },
-    "trim(exp)": { "index": 107, "kind": "function", "displayName": "Trim", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The trim function trims the message body (or 
expression) by removing all leading and trailing white spaces.", "ognl": false, 
"suffix": "}" },
-    "type:name.field": { "index": 108, "kind": "function", "displayName": 
"Java Field Value", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "To refer to a type or 
field by its classname. To refer to a field, you can append .FIELD_NAME. For 
example, you can refer to the constant field from Exchange as: 
`org.apache.camel.Exchange.FILE_NAME`", "ognl":  [...]
-    "kindOfType(exp)": { "index": 109, "kind": "function", "displayName": 
"Kind of Type", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "What kind of type is 
the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": 
"}" },
-    "unquote(exp)": { "index": 110, "kind": "function", "displayName": 
"Unquote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) with any leading\/ending quotes removed", "ognl": false, 
"suffix": "}" },
-    "uppercase(exp)": { "index": 111, "kind": "function", "displayName": 
"Uppercase", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Uppercases the message 
body (or expression)", "ognl": false, "suffix": "}" },
-    "uuid(type)": { "index": 112, "kind": "function", "displayName": "Generate 
UUID", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a UUID using the 
Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and 
`simple` as the type. If no type is given, the default is used. It is also 
possible to use a custom `UuidGenera [...]
-    "val(exp)": { "index": 113, "kind": "function", "displayName": "Value", 
"group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the expression as a constant value", 
"ognl": false, "suffix": "}" },
-    "variable.name": { "index": 114, "kind": "function", "displayName": 
"Variable", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The variable with the 
given name", "ognl": true, "suffix": "}" },
-    "variableAs(key,type)": { "index": 115, "kind": "function", "displayName": 
"Variable As", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the variable to 
the given type (classname).", "ognl": false, "suffix": "}" },
-    "variables": { "index": 116, "kind": "function", "displayName": 
"Variables", "group": "core", "label": "core", "required": false, "javaType": 
"java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns all the variables 
from the current Exchange in a Map", "ognl": false, "suffix": "}" },
-    "xpath(input,exp)": { "index": 117, "kind": "function", "displayName": 
"XPath", "group": "xml", "label": "xml", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "When working with XML 
data, then this allows using the XPath language, for example, to extract data 
from the message body (in XML format). This requires having camel-xpath JAR on 
the classpath. For input (optional), you ca [...]
+    "toPrettyJson(exp)": { "index": 77, "kind": "function", "displayName": "To 
Pretty JSon", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
JSon String representation.", "ognl": false, "suffix": "}" },
+    "toPrettyJsonBody": { "index": 78, "kind": "function", "displayName": "To 
Pretty JSon Body", "group": "json", "label": "json", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Converts the body to 
JSon String representation.", "ognl": false, "suffix": "}" },
+    "toJson(exp)": { "index": 79, "kind": "function", "displayName": "To 
JSon", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the expression to 
JSon String representation.", "ognl": false, "suffix": "}" },
+    "toJsonBody": { "index": 80, "kind": "function", "displayName": "To JSon 
Body", "group": "json", "label": "json", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the body to JSon 
String representation.", "ognl": false, "suffix": "}" },
+    "properties:key:default": { "index": 81, "kind": "function", 
"displayName": "Property Placeholder", "group": "core", "label": "core", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Lookup a property placeholder with the given key. If the key does not exist 
nor has a value, then an optional default value can be specified.", "ognl": 
false, "suffix": "}" },
+    "propertiesExist:key": { "index": 82, "kind": "function", "displayName": 
"Property Placeholder Exists", "group": "core", "label": "core", "required": 
false, "javaType": "boolean", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Checks whether a property placeholder with the given key exists or not. The 
result can be negated by prefixing the key with !", "ognl": false, "suffix": 
"}" },
+    "quote(exp)": { "index": 83, "kind": "function", "displayName": "Quote", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the message body (or expression) as a 
double quoted string", "ognl": false, "suffix": "}" },
+    "random(min,max)": { "index": 84, "kind": "function", "displayName": 
"Random", "group": "number", "label": "number", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns a random number between min and 
max (exclusive)", "ognl": false, "suffix": "}" },
+    "range(min,max)": { "index": 85, "kind": "function", "displayName": 
"Range", "group": "number", "label": "number", "required": false, "javaType": 
"List", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a list of 
increasing integers between the given interval (exclusive)", "ognl": false, 
"suffix": "}" },
+    "ref:name": { "index": 86, "kind": "function", "displayName": "Bean By 
Id", "group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "To look up a bean from the Registry with the 
given name.", "ognl": false, "suffix": "}" },
+    "replace(from,to,exp)": { "index": 87, "kind": "function", "displayName": 
"Replace String Values", "group": "string", "label": "string", "required": 
false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Replace all the string values in the message body\/expression. To make it 
easier to replace single and double quotes, then you can use XML escaped values 
`\\&quot;` as double quote, `\\&apos;` as s [...]
+    "reverse(val...)": { "index": 88, "kind": "function", "displayName": 
"Reverse Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values, but in reverse order", "ognl": false, 
"suffix": "}" },
+    "routeGroup": { "index": 89, "kind": "function", "displayName": "Route 
Group", "group": "core", "label": "core", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The route group of the 
current route the Exchange is being routed. Not all routes have a group 
assigned, so this may be null.", "ognl": false, "suffix": "}" },
+    "routeId": { "index": 90, "kind": "function", "displayName": "Route Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The route id of the current route the Exchange 
is being routed", "ognl": false, "suffix": "}" },
+    "safeQuote(exp)": { "index": 91, "kind": "function", "displayName": "Safe 
Quote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) safely quoted if needed", "ognl": false, "suffix": "}" },
+    "setVariable(key,exp)": { "index": 92, "kind": "function", "displayName": 
"Set Variable", "group": "attachment", "label": "attachment", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets an attachment with payload from the message body\/expression.", "ognl": 
false, "suffix": "}" },
+    "setHeader(name,type,exp)": { "index": 93, "kind": "function", 
"displayName": "Set Header", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a message header with the given expression (optional converting to the 
given type)", "ognl": false, "suffix": "}" },
+    "setVariable(name,type,exp)": { "index": 94, "kind": "function", 
"displayName": "Set Variable", "group": "core", "label": "core", "required": 
false, "javaType": "Object", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sets a variable with the given expression (optional converting to the given 
type)", "ognl": false, "suffix": "}" },
+    "shuffle(val...)": { "index": 95, "kind": "function", "displayName": 
"Shuffle Values", "group": "collection", "label": "collection", "required": 
false, "javaType": "List", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a list of all the values shuffled in random order", "ognl": false, 
"suffix": "}" },
+    "size(exp)": { "index": 96, "kind": "function", "displayName": "Size", 
"group": "collection", "label": "collection", "required": false, "javaType": 
"int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Returns the number of elements in 
collection or array based payloads. If the value is null then 0 is returned, 
otherwise 1.", "ognl": false, "suffix": "}" },
+    "skip(num)": { "index": 97, "kind": "function", "displayName": "Skip First 
Items from the Message Body", "group": "collection", "label": "collection", 
"required": false, "javaType": "java.util.Iterator", "prefix": "${", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The skip function iterates the message body and skips 
the first number of items. This can be used with the Splitter EIP to split a 
message body and skip the first N number [...]
+    "split(exp,separator)": { "index": 98, "kind": "function", "displayName": 
"Split String Values", "group": "collection", "label": "collection", 
"required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Splits the message body\/expression as a String value using the separator into 
a String array", "ognl": false, "suffix": "}" },
+    "stepId": { "index": 99, "kind": "function", "displayName": "Step Id", 
"group": "core", "label": "core", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current step the 
Exchange is being routed.", "ognl": false, "suffix": "}" },
+    "substring(head,tail)": { "index": 100, "kind": "function", "displayName": 
"Substring", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Returns a substring of 
the message body\/expression. If only one positive number, then the returned 
string is clipped from the beginning. If only one negative number, then the 
returned string is clipped from  [...]
+    "substringAfter(exp,before)": { "index": 101, "kind": "function", 
"displayName": "Substring After", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes after. Returns 
null if nothing comes after.", "ognl": false, "suffix": "}" },
+    "substringBefore(exp,before)": { "index": 102, "kind": "function", 
"displayName": "Substring Before", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that comes before. Returns 
null if nothing comes before.", "ognl": false, "suffix": "}" },
+    "substringBetween(exp,after,before)": { "index": 103, "kind": "function", 
"displayName": "Substring Between", "group": "string", "label": "string", 
"required": false, "javaType": "String", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Returns a substring of the message body\/expression that are between after and 
before. Returns null if nothing comes between.", "ognl": false, "suffix": "}" },
+    "sum(val...)": { "index": 104, "kind": "function", "displayName": 
"Calculate Sum Number", "group": "number", "label": "number", "required": 
false, "javaType": "long", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Sums together all the values as integral numbers. This function can also be 
used to subtract by using negative numbers.", "ognl": false, "suffix": "}" },
+    "sys.name": { "index": 105, "kind": "function", "displayName": "JVM System 
Property", "group": "other", "label": "other", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The JVM system property 
with the given name", "ognl": false, "suffix": "}" },
+    "threadId": { "index": 106, "kind": "function", "displayName": "Thread 
Id", "group": "other", "label": "other", "required": false, "javaType": "long", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the id of the current thread. Can be 
used for logging.", "ognl": false, "suffix": "}" },
+    "threadName": { "index": 107, "kind": "function", "displayName": "Thread 
Name", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the name of the 
current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
+    "throwException(type,msg)": { "index": 108, "kind": "function", 
"displayName": "Throw Exception", "group": "core", "label": "core", "required": 
false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": 
"Deliberately throws an error. Uses IllegalArgumentException by default if no 
type is specified (use fully qualified classname).", "ognl": false, "suffix": 
"}" },
+    "trim(exp)": { "index": 109, "kind": "function", "displayName": "Trim", 
"group": "string", "label": "string", "required": false, "javaType": "String", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The trim function trims the message body (or 
expression) by removing all leading and trailing white spaces.", "ognl": false, 
"suffix": "}" },
+    "type:name.field": { "index": 110, "kind": "function", "displayName": 
"Java Field Value", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "To refer to a type or 
field by its classname. To refer to a field, you can append .FIELD_NAME. For 
example, you can refer to the constant field from Exchange as: 
`org.apache.camel.Exchange.FILE_NAME`", "ognl":  [...]
+    "kindOfType(exp)": { "index": 111, "kind": "function", "displayName": 
"Kind of Type", "group": "core", "label": "core", "required": false, 
"javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "What kind of type is 
the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": 
"}" },
+    "unquote(exp)": { "index": 112, "kind": "function", "displayName": 
"Unquote", "group": "string", "label": "string", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns the message body 
(or expression) with any leading\/ending quotes removed", "ognl": false, 
"suffix": "}" },
+    "uppercase(exp)": { "index": 113, "kind": "function", "displayName": 
"Uppercase", "group": "string", "label": "string", "required": false, 
"javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": 
"", "autowired": false, "secret": false, "description": "Uppercases the message 
body (or expression)", "ognl": false, "suffix": "}" },
+    "uuid(type)": { "index": 114, "kind": "function", "displayName": "Generate 
UUID", "group": "other", "label": "other", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns a UUID using the 
Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and 
`simple` as the type. If no type is given, the default is used. It is also 
possible to use a custom `UuidGenera [...]
+    "val(exp)": { "index": 115, "kind": "function", "displayName": "Value", 
"group": "core", "label": "core", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Returns the expression as a constant value", 
"ognl": false, "suffix": "}" },
+    "variable.name": { "index": 116, "kind": "function", "displayName": 
"Variable", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The variable with the 
given name", "ognl": true, "suffix": "}" },
+    "variableAs(key,type)": { "index": 117, "kind": "function", "displayName": 
"Variable As", "group": "core", "label": "core", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Converts the variable to 
the given type (classname).", "ognl": false, "suffix": "}" },
+    "variables": { "index": 118, "kind": "function", "displayName": 
"Variables", "group": "core", "label": "core", "required": false, "javaType": 
"java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "Returns all the variables 
from the current Exchange in a Map", "ognl": false, "suffix": "}" },
+    "xpath(input,exp)": { "index": 119, "kind": "function", "displayName": 
"XPath", "group": "xml", "label": "xml", "required": false, "javaType": 
"Object", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "When working with XML 
data, then this allows using the XPath language, for example, to extract data 
from the message body (in XML format). This requires having camel-xpath JAR on 
the classpath. For input (optional), you ca [...]
   }
 }
diff --git 
a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
 
b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
index 9366a2863868..e86b71e3ba1f 100644
--- 
a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
+++ 
b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
@@ -594,6 +594,8 @@ Functions to work with XML and JSon payloads.
 |`prettyBody` | `String` | Converts the message body to a `String`, and 
attempts to pretty print (if JSon or XML) otherwise return the value as-is.
 |`toJson(exp)` | `String` | Converts the expression to a JSon `String` 
representation. String values are returned as-is, null values return null, all 
other types are serialized to JSon.
 |`toJsonBody` | `String` | Converts the message body to a JSon `String` 
representation. String values are returned as-is, null values return null, all 
other types are serialized to JSon.
+|`toPrettyJson(exp)` | `String` | Converts the expression to a JSon `String` 
representation. String values are returned as-is, null values return null, all 
other types are serialized to JSon in pretty mode.
+|`toPrettyJsonBody` | `String` | Converts the message body to a JSon `String` 
representation. String values are returned as-is, null values return null, all 
other types are serialized to JSon in pretty mode.
 |`xpath(exp)` | `Object` | When working with XML data, then this allows using 
the XPath language, for example, to extract data from the message body (in XML 
format). This requires having camel-xpath JAR on the classpath.
 |`xpath(input,exp)` | `Object` | When working with XML data, then this allows 
using the XPath language, for example, to extract data from the message body 
(in XML format). This requires having camel-xpath JAR on the classpath. For 
input you can choose `header:key`, `exchangeProperty:key` or `variable:key` to 
use as input for the JSon payload instead of the message body.
 |====
@@ -643,6 +645,21 @@ from("direct:map")
         .to("log:data");
 ----
 
+The `toJson` function is to convert the payload to JSon as a `String` value. 
However if the payload is already a `String` then no conversion happens.
+So suppose the payload is a `Map` object as follows:
+
+[source,java]
+----
+Map<String, Object> map = new LinkedHashMap<>();
+map.put("name", "Jack");
+map.put("id", 123);
+----
+
+Then `toJson` will output: `{"name":"Jack","id":123}`.
+
+There are also _pretty_ alternatives so when calling `toPrettyJson` will 
output: TODO:
+
+
 The `xpath` function is for working with XML and using XPath expressions to 
extract data from XML payloads.
 
 Given the following XML payload:
diff --git 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
index c55afba93407..8d66f869d6bb 100644
--- 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
+++ 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
@@ -252,7 +252,7 @@ public final class CSimpleHelper {
         return body;
     }
 
-    public static String toJsonBody(Exchange exchange) {
+    public static String toJsonBody(Exchange exchange, boolean pretty) {
         Object body = exchange.getIn().getBody();
         if (body == null) {
             return null;
@@ -266,7 +266,11 @@ public final class CSimpleHelper {
         } catch (final java.io.IOException caught) {
             /* See StringWriter. */
         }
-        return writer.toString();
+        String answer = writer.toString();
+        if (pretty && answer != null) {
+            answer = Jsoner.prettyPrint(answer);
+        }
+        return answer;
     }
 
     private static String prettyXml(String rawXml) {
diff --git 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
index ef385c54b9ee..5cc4d8dcf988 100644
--- 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
+++ 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
@@ -314,6 +314,14 @@ public final class SimpleConstants {
               javaType = "String", label = "json,xml")
     public static final String PRETTY_BODY = "prettyBody";
 
+    @Metadata(description = "Converts the expression to JSon String 
representation.",
+              label = "json", javaType = "String", displayName = "To Pretty 
JSon")
+    public static final String TO_PRETTY_JSON = "toPrettyJson(exp)";
+
+    @Metadata(description = "Converts the body to JSon String representation.",
+              javaType = "String", label = "json", displayName = "To Pretty 
JSon Body")
+    public static final String TO_PRETTY_JSON_BODY = "toPrettyJsonBody";
+
     @Metadata(description = "Converts the expression to JSon String 
representation.",
               label = "json", javaType = "String", displayName = "To JSon")
     public static final String TO_JSON = "toJson(exp)";
diff --git 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index 5ab85cba6f8a..4f29de8ecdd5 100644
--- 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -212,7 +212,18 @@ public class SimpleFunctionExpression extends 
LiteralExpression {
             }
             exp = StringHelper.removeLeadingAndEndingQuotes(exp);
             Expression inlined = 
camelContext.resolveLanguage("simple").createExpression(exp);
-            return ExpressionBuilder.toJsonExpression(inlined);
+            return ExpressionBuilder.toJsonExpression(inlined, false);
+        }
+        // toPrettyJson
+        remainder = ifStartsWithReturnRemainder("toPrettyJson(", function);
+        if (remainder != null) {
+            String exp = StringHelper.beforeLast(remainder, ")");
+            if (exp == null) {
+                throw new SimpleParserException("Valid syntax: 
${toPrettyJson(exp)} was: " + function, token.getIndex());
+            }
+            exp = StringHelper.removeLeadingAndEndingQuotes(exp);
+            Expression inlined = 
camelContext.resolveLanguage("simple").createExpression(exp);
+            return ExpressionBuilder.toJsonExpression(inlined, true);
         }
 
         // file: prefix
@@ -732,7 +743,9 @@ public class SimpleFunctionExpression extends 
LiteralExpression {
         } else if (ObjectHelper.equal(expression, "prettyBody")) {
             return ExpressionBuilder.prettyBodyExpression();
         } else if (ObjectHelper.equal(expression, "toJsonBody")) {
-            return ExpressionBuilder.toJsonBodyExpression();
+            return 
ExpressionBuilder.toJsonExpression(ExpressionBuilder.bodyExpression(), false);
+        } else if (ObjectHelper.equal(expression, "toPrettyJsonBody")) {
+            return 
ExpressionBuilder.toJsonExpression(ExpressionBuilder.bodyExpression(), true);
         } else if (ObjectHelper.equal(expression, "bodyOneLine")) {
             return ExpressionBuilder.bodyOneLine();
         } else if (ObjectHelper.equal(expression, "originalBody")) {
@@ -2002,7 +2015,9 @@ public class SimpleFunctionExpression extends 
LiteralExpression {
         } else if (ObjectHelper.equal(expression, "prettyBody")) {
             return "prettyBody(exchange)";
         } else if (ObjectHelper.equal(expression, "toJsonBody")) {
-            return "toJsonBody(exchange)";
+            return "toJsonBody(exchange, false)";
+        } else if (ObjectHelper.equal(expression, "toPrettyJsonBody")) {
+            return "toJsonBody(exchange, true)";
         } else if (ObjectHelper.equal(expression, "bodyOneLine")) {
             return "bodyOneLine(exchange)";
         } else if (ObjectHelper.equal(expression, "id")) {
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index f9b8f90a19d9..ec45d686906f 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -60,6 +60,7 @@ import org.apache.camel.support.ExchangeHelper;
 import org.apache.camel.support.LanguageHelper;
 import org.apache.camel.util.InetAddressUtil;
 import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.json.Jsoner;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.parallel.ResourceLock;
 import org.junit.jupiter.api.parallel.Resources;
@@ -3304,19 +3305,32 @@ public class SimpleTest extends LanguageTestSupport {
         exchange.getMessage().setBody(map);
         assertExpression(exchange, "${toJson(${body})}", 
"{\"name\":\"Jack\",\"id\":123}");
         assertExpression(exchange, "${toJsonBody}", 
"{\"name\":\"Jack\",\"id\":123}");
+        // pretty mode
+        String pretty = Jsoner.prettyPrint("{\"name\":\"Jack\",\"id\":123}");
+        assertExpression(exchange, "${toPrettyJson(${body})}", pretty);
+        assertExpression(exchange, "${toPrettyJsonBody}", pretty);
 
         // list body is serialized to JSON array
         exchange.getMessage().setBody(List.of("a", "b", "c"));
         assertExpression(exchange, "${toJson(${body})}", 
"[\"a\",\"b\",\"c\"]");
+        // pretty mode
+        pretty = Jsoner.prettyPrint("[\"a\",\"b\",\"c\"]");
+        assertExpression(exchange, "${toPrettyJson(${body})}", pretty);
+        assertExpression(exchange, "${toPrettyJsonBody}", pretty);
 
         // null body
         exchange.getMessage().setBody(null);
         assertExpression(exchange, "${toJsonBody}", null);
         assertExpression(exchange, "${toJson(${body})}", null);
+        // pretty mode
+        assertExpression(exchange, "${toPrettyJsonBody}", null);
+        assertExpression(exchange, "${toPrettyJson(${body})}", null);
 
         // toJson with a header expression
         exchange.getMessage().setHeader("myNum", 42);
         assertExpression(exchange, "${toJson(${header.myNum})}", "42");
+        // pretty mode
+        assertExpression(exchange, "${toPrettyJson(${header.myNum})}", "42");
     }
 
     @Test
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
index d880ff721027..f4f94047e836 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
@@ -2744,7 +2744,7 @@ public class ExpressionBuilder {
     /**
      * Returns the expression result serialized as a JSON string
      */
-    public static Expression toJsonExpression(final Expression expression) {
+    public static Expression toJsonExpression(final Expression expression, 
boolean pretty) {
         return new ExpressionAdapter() {
             @Override
             public Object evaluate(Exchange exchange) {
@@ -2755,36 +2755,20 @@ public class ExpressionBuilder {
                 if (value instanceof String) {
                     return value;
                 }
-                return serializeCarelessly(value);
-            }
-
-            @Override
-            public String toString() {
-                return "toJson(" + expression + ")";
-            }
-        };
-    }
-
-    /**
-     * Returns the message body serialized as a JSON string
-     */
-    public static Expression toJsonBodyExpression() {
-        return new ExpressionAdapter() {
-            @Override
-            public Object evaluate(Exchange exchange) {
-                Object body = exchange.getIn().getBody();
-                if (body == null) {
-                    return null;
-                }
-                if (body instanceof String) {
-                    return body;
+                String answer = serializeCarelessly(value);
+                if (answer != null && pretty) {
+                    answer = answer.trim();
+                    // only pretty print if json structure
+                    if (answer.startsWith("{") && answer.endsWith("}") || 
answer.startsWith("[") && answer.endsWith("]")) {
+                        answer = Jsoner.prettyPrint(answer);
+                    }
                 }
-                return serializeCarelessly(body);
+                return answer;
             }
 
             @Override
             public String toString() {
-                return "toJsonBody";
+                return "toJson(" + expression + ")";
             }
         };
     }
diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/SimpleUtils.java 
b/core/camel-util/src/main/java/org/apache/camel/util/SimpleUtils.java
index 749f981ecc56..49b0fd4dd51c 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/SimpleUtils.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/SimpleUtils.java
@@ -132,6 +132,8 @@ public class SimpleUtils {
                     "throwexception",
                     "tojson",
                     "tojsonbody",
+                    "toprettyjson",
+                    "toprettyjsonbody",
                     "trim",
                     "type",
                     "unquote",

Reply via email to