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 be9b5f61738f CAMEL-22844: camel-core - Add pretty option to simple 
language (#20784)
be9b5f61738f is described below

commit be9b5f61738f819b7f89ee734d279cd0a5096c4f
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jan 13 07:24:12 2026 +0100

    CAMEL-22844: camel-core - Add pretty option to simple language (#20784)
---
 .../apache/camel/catalog/languages/csimple.json    |   5 +-
 .../org/apache/camel/catalog/languages/file.json   |   5 +-
 .../org/apache/camel/catalog/languages/simple.json |   5 +-
 .../org/apache/camel/catalog/models/csimple.json   |   5 +-
 .../org/apache/camel/catalog/models/simple.json    |   5 +-
 .../apache/camel/catalog/schemas/camel-spring.xsd  |  24 ++++-
 .../apache/camel/catalog/schemas/camel-xml-io.xsd  |  24 ++++-
 .../camel/spring/SpringSimplePrettyTest.java       |  74 ++++++++++++++
 .../apache/camel/spring/SpringSimplePrettyTest.xml |  51 ++++++++++
 .../org/apache/camel/language/csimple/csimple.json |   5 +-
 .../org/apache/camel/language/simple/file.json     |   5 +-
 .../org/apache/camel/language/simple/simple.json   |   5 +-
 .../camel/language/csimple/CSimpleLanguage.java    |  15 ++-
 .../camel/language/simple/SimpleLanguage.java      |   8 +-
 .../org/apache/camel/model/language/csimple.json   |   5 +-
 .../org/apache/camel/model/language/simple.json    |   5 +-
 .../java/org/apache/camel/builder/Builder.java     |  10 ++
 .../org/apache/camel/builder/BuilderSupport.java   |  18 +++-
 .../org/apache/camel/builder/ExpressionClause.java |  23 +++++
 .../camel/builder/ExpressionClauseSupport.java     |  30 ++++++
 .../camel/model/language/CSimpleExpression.java    |  36 +++++++
 .../camel/model/language/SimpleExpression.java     |  36 +++++++
 .../reifier/language/CSimpleExpressionReifier.java |   9 ++
 .../reifier/language/SimpleExpressionReifier.java  |   3 +-
 .../camel/language/simple/SimplePrettyTest.java    |  89 +++++++++++++++++
 .../java/org/apache/camel/xml/in/ModelParser.java  |  10 +-
 .../java/org/apache/camel/xml/out/ModelWriter.java |   2 +
 .../org/apache/camel/yaml/out/ModelWriter.java     |   2 +
 .../dsl/yaml/deserializers/ModelDeserializers.java |  12 +++
 .../generated/resources/schema/camelYamlDsl.json   |  12 +++
 .../apache/camel/dsl/yaml/SimplePrettyTest.groovy  | 110 +++++++++++++++++++++
 31 files changed, 612 insertions(+), 36 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/csimple.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/csimple.json
index ef9e98c9ff49..2bcb2fcecc13 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/csimple.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/csimple.json
@@ -18,7 +18,8 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
index 889baa9102df..05ff5def68ba 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
@@ -18,8 +18,9 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   },
   "functions": {
     "file:name": { "index": 0, "kind": "function", "displayName": "File", 
"group": "function", "label": "function", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The file name (relative 
from starting directory)", "ognl": false, "suffix": "}" },
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 dfb090c0713e..a05d2db62f8b 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
@@ -18,8 +18,9 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   },
   "functions": {
     "body": { "index": 0, "kind": "function", "displayName": "Body", "group": 
"function", "label": "function", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The message body", "ognl": true, "suffix": "}" 
},
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/csimple.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/csimple.json
index e2f4425ae387..85242d03bee3 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/csimple.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/csimple.json
@@ -15,7 +15,8 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/simple.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/simple.json
index 5bf25c834e4b..c96254a8d472 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/simple.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/simple.json
@@ -15,7 +15,8 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index fa6796c0b9fa..a36684457940 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -17336,7 +17336,17 @@ Refers to a custom KeyGenerator to lookup from the 
register for KEM operations.
   </xs:complexType>
   <xs:complexType name="cSimpleExpression">
     <xs:simpleContent>
-      <xs:extension base="tns:typedExpressionDefinition"/>
+      <xs:extension base="tns:typedExpressionDefinition">
+        <xs:attribute name="pretty" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+To pretty format the output (only JSon or XML supported). Default value: false
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+      </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType abstract="true" name="typedExpressionDefinition">
@@ -17643,7 +17653,17 @@ Whether to validate the bean has the configured 
method. Default value: true
   </xs:complexType>
   <xs:complexType name="simpleExpression">
     <xs:simpleContent>
-      <xs:extension base="tns:typedExpressionDefinition"/>
+      <xs:extension base="tns:typedExpressionDefinition">
+        <xs:attribute name="pretty" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+To pretty format the output (only JSon or XML supported). Default value: false
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+      </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="spELExpression">
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
index 03ac2e467303..20e6f8a99e64 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
@@ -16030,7 +16030,17 @@ Refers to a custom KeyGenerator to lookup from the 
register for KEM operations.
   </xs:complexType>
   <xs:complexType name="cSimpleExpression">
     <xs:simpleContent>
-      <xs:extension base="tns:typedExpressionDefinition"/>
+      <xs:extension base="tns:typedExpressionDefinition">
+        <xs:attribute name="pretty" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+To pretty format the output (only JSon or XML supported). Default value: false
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+      </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType abstract="true" name="typedExpressionDefinition">
@@ -16337,7 +16347,17 @@ Whether to validate the bean has the configured 
method. Default value: true
   </xs:complexType>
   <xs:complexType name="simpleExpression">
     <xs:simpleContent>
-      <xs:extension base="tns:typedExpressionDefinition"/>
+      <xs:extension base="tns:typedExpressionDefinition">
+        <xs:attribute name="pretty" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+To pretty format the output (only JSon or XML supported). Default value: false
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+      </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="spELExpression">
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringSimplePrettyTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringSimplePrettyTest.java
new file mode 100644
index 000000000000..27b8916c0234
--- /dev/null
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringSimplePrettyTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringSimplePrettyTest extends SpringTestSupport {
+
+    private static final String XML = """
+            <person>
+              <name>
+                Jack
+              </name>
+            </person>""";
+
+    private static final String JSON = """
+            {
+               "name": "Jack",
+               "age": 44
+            }
+            """;
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/spring/SpringSimplePrettyTest.xml");
+    }
+
+    @Test
+    public void testPrettyXml() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived(XML);
+
+        template.sendBody("direct:xml", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testPrettyJSon() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived(JSON);
+
+        template.sendBody("direct:json", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testPrettyText() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:text", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+}
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/SpringSimplePrettyTest.xml
 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/SpringSimplePrettyTest.xml
new file mode 100644
index 000000000000..f7689f124ba5
--- /dev/null
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/SpringSimplePrettyTest.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring";>
+    <route>
+      <from uri="direct:xml"/>
+      <setBody>
+        <simple 
pretty="true">&lt;person&gt;&lt;name&gt;Jack&lt;/name&gt;&lt;/person&gt;</simple>
+      </setBody>
+      <to uri="mock:result"/>
+    </route>
+    <route>
+      <from uri="direct:json"/>
+      <setBody>
+        <simple pretty="true">{ "name": "Jack", "age": 44 }</simple>
+      </setBody>
+      <to uri="mock:result"/>
+    </route>
+    <route>
+      <from uri="direct:text"/>
+      <setBody>
+        <simple pretty="true">Hello ${body}</simple>
+      </setBody>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+</beans>
diff --git 
a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/csimple/csimple.json
 
b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/csimple/csimple.json
index ef9e98c9ff49..2bcb2fcecc13 100644
--- 
a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/csimple/csimple.json
+++ 
b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/csimple/csimple.json
@@ -18,7 +18,8 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   }
 }
diff --git 
a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
 
b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
index 889baa9102df..05ff5def68ba 100644
--- 
a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
+++ 
b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
@@ -18,8 +18,9 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   },
   "functions": {
     "file:name": { "index": 0, "kind": "function", "displayName": "File", 
"group": "function", "label": "function", "required": false, "javaType": 
"String", "prefix": "${", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The file name (relative 
from starting directory)", "ognl": false, "suffix": "}" },
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 dfb090c0713e..a05d2db62f8b 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
@@ -18,8 +18,9 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   },
   "functions": {
     "body": { "index": 0, "kind": "function", "displayName": "Body", "group": 
"function", "label": "function", "required": false, "javaType": "Object", 
"prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "The message body", "ognl": true, "suffix": "}" 
},
diff --git 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleLanguage.java
 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleLanguage.java
index 86b389e9c30c..30d349ef0f0f 100644
--- 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleLanguage.java
+++ 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleLanguage.java
@@ -148,15 +148,20 @@ public class CSimpleLanguage extends TypedLanguageSupport 
implements StaticServi
     @Override
     public Expression createExpression(String expression, Object[] properties) 
{
         Class<?> resultType = property(Class.class, properties, 0, null);
+        boolean pretty = property(boolean.class, properties, 2, false);
         if (Boolean.class == resultType || boolean.class == resultType) {
             // we want it compiled as a predicate
             return (Expression) createPredicate(expression);
-        } else if (resultType == null || resultType == Object.class) {
-            // No specific result type has been provided
-            return createExpression(expression);
+        } else {
+            Expression exp = createExpression(expression);
+            if (resultType != null) {
+                exp = ExpressionBuilder.convertToExpression(exp, resultType);
+            }
+            if (pretty) {
+                exp = ExpressionBuilder.prettyExpression(exp);
+            }
+            return exp;
         }
-        // A specific result type has been provided
-        return 
ExpressionBuilder.convertToExpression(createExpression(expression), resultType);
     }
 
     @Override
diff --git 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index 1681730fe86e..57428cb6bc09 100644
--- 
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ 
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -158,13 +158,14 @@ public class SimpleLanguage extends LanguageSupport 
implements StaticService {
     public Expression createExpression(String expression, Object[] properties) 
{
         Class<?> resultType = property(Class.class, properties, 0, null);
         boolean trim = property(boolean.class, properties, 1, true);
+        boolean pretty = property(boolean.class, properties, 2, false);
         if (trim && expression != null) {
             expression = expression.trim();
         }
         if (expression == null) {
             expression = "${null}";
         }
-        return createExpression(expression, resultType);
+        return createExpression(expression, resultType, pretty);
     }
 
     @Override
@@ -202,7 +203,7 @@ public class SimpleLanguage extends LanguageSupport 
implements StaticService {
         return answer;
     }
 
-    public Expression createExpression(String expression, Class<?> resultType) 
{
+    public Expression createExpression(String expression, Class<?> resultType, 
boolean pretty) {
         if (resultType == Boolean.class || resultType == boolean.class) {
             // if its a boolean as result then its a predicate
             Predicate predicate = createPredicate(expression);
@@ -212,6 +213,9 @@ public class SimpleLanguage extends LanguageSupport 
implements StaticService {
             if (resultType != null) {
                 exp = ExpressionBuilder.convertToExpression(exp, resultType);
             }
+            if (pretty) {
+                exp = ExpressionBuilder.prettyExpression(exp);
+            }
             return exp;
         }
     }
diff --git 
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/csimple.json
 
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/csimple.json
index e2f4425ae387..85242d03bee3 100644
--- 
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/csimple.json
+++ 
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/csimple.json
@@ -15,7 +15,8 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   }
 }
diff --git 
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/simple.json
 
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/simple.json
index 5bf25c834e4b..c96254a8d472 100644
--- 
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/simple.json
+++ 
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/simple.json
@@ -15,7 +15,8 @@
   "properties": {
     "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": 
"common", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the id of this node" },
     "expression": { "index": 1, "kind": "value", "displayName": "Expression", 
"group": "common", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The expression value in your chosen language syntax" },
-    "resultType": { "index": 2, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
-    "trim": { "index": 3, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
+    "pretty": { "index": 2, "kind": "attribute", "displayName": "Pretty", 
"group": "common", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "To pretty format the output (only JSon 
or XML supported)" },
+    "resultType": { "index": 3, "kind": "attribute", "displayName": "Result 
Type", "group": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Sets the class of the result type (type from output)" },
+    "trim": { "index": 4, "kind": "attribute", "displayName": "Trim", "group": 
"advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" }
   }
 }
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/Builder.java 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/Builder.java
index 9846d6807ec3..7b555323d024 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/builder/Builder.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/Builder.java
@@ -180,6 +180,16 @@ public final class Builder {
         return new ValueBuilder(exp);
     }
 
+    /**
+     * Returns a simple expression
+     */
+    public static ValueBuilder simple(String value, Class<?> resultType, 
boolean pretty) {
+        SimpleExpression exp = new SimpleExpression(value);
+        exp.setResultType(resultType);
+        exp.setPretty(Boolean.toString(pretty));
+        return new ValueBuilder(exp);
+    }
+
     /**
      * Returns a JOOR expression value builder
      */
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/BuilderSupport.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/BuilderSupport.java
index 8b57e17d80f7..18ace272c0a5 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/BuilderSupport.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/BuilderSupport.java
@@ -232,14 +232,28 @@ public abstract class BuilderSupport implements 
CamelContextAware {
      * Returns a simple expression value builder
      */
     public ValueBuilder simple(String value) {
-        return simple(value, null);
+        return simple(value, null, false);
+    }
+
+    /**
+     * Returns a simple expression value builder
+     */
+    public ValueBuilder simple(String value, boolean pretty) {
+        return simple(value, null, false);
     }
 
     /**
      * Returns a simple expression value builder
      */
     public ValueBuilder simple(String value, Class<?> resultType) {
-        return Builder.simple(value, resultType);
+        return simple(value, resultType, false);
+    }
+
+    /**
+     * Returns a simple expression value builder
+     */
+    public ValueBuilder simple(String value, Class<?> resultType, boolean 
pretty) {
+        return Builder.simple(value, resultType, pretty);
     }
 
     /**
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClause.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClause.java
index 1e35a2829c2a..73537c07890f 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -627,6 +627,17 @@ public class ExpressionClause<T> implements Expression, 
Predicate {
         return delegate.simple(text);
     }
 
+    /**
+     * Evaluates a <a href="http://camel.apache.org/simple.html";>Simple 
expression</a>
+     *
+     * @param  text   the expression to be evaluated
+     * @param  pretty format pretty (only XML or JSon output supported)
+     * @return        the builder to continue processing the DSL
+     */
+    public T simple(String text, boolean pretty) {
+        return delegate.simple(text, pretty);
+    }
+
     /**
      * Evaluates a <a href="http://camel.apache.org/simple.html";>Simple 
expression</a>
      *
@@ -638,6 +649,18 @@ public class ExpressionClause<T> implements Expression, 
Predicate {
         return delegate.simple(text, resultType);
     }
 
+    /**
+     * Evaluates a <a href="http://camel.apache.org/simple.html";>Simple 
expression</a>
+     *
+     * @param  text       the expression to be evaluated
+     * @param  resultType the result type
+     * @param  pretty     format pretty (only XML or JSon output supported)
+     * @return            the builder to continue processing the DSL
+     */
+    public T simple(String text, Class<?> resultType, boolean pretty) {
+        return delegate.simple(text, resultType, pretty);
+    }
+
     /**
      * Evaluates a token expression on the message body
      *
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index 517ab16dd59b..82c302557776 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -767,6 +767,20 @@ public class ExpressionClauseSupport<T> implements 
ExpressionFactoryAware, Predi
         return expression(new SimpleExpression(text));
     }
 
+    /**
+     * Evaluates a <a href="http://camel.apache.org/simple.html";>Simple 
expression</a>
+     *
+     * @param  text   the expression to be evaluated
+     * @param  pretty format pretty (only XML or JSon output supported)
+     * @return        the builder to continue processing the DSL
+     */
+    public T simple(String text, boolean pretty) {
+        SimpleExpression expression = new SimpleExpression(text);
+        expression.setPretty(Boolean.toString(pretty));
+        expression(expression);
+        return result;
+    }
+
     /**
      * Evaluates a <a href="http://camel.apache.org/simple.html";>Simple 
expression</a>
      *
@@ -781,6 +795,22 @@ public class ExpressionClauseSupport<T> implements 
ExpressionFactoryAware, Predi
         return result;
     }
 
+    /**
+     * Evaluates a <a href="http://camel.apache.org/simple.html";>Simple 
expression</a>
+     *
+     * @param  text       the expression to be evaluated
+     * @param  resultType the result type
+     * @param  pretty     format pretty (only XML or JSon output supported)
+     * @return            the builder to continue processing the DSL
+     */
+    public T simple(String text, Class<?> resultType, boolean pretty) {
+        SimpleExpression expression = new SimpleExpression(text);
+        expression.setResultType(resultType);
+        expression.setPretty(Boolean.toString(pretty));
+        expression(expression);
+        return result;
+    }
+
     /**
      * Evaluates an <a href="http://camel.apache.org/hl7.html";>HL7 Terser 
expression</a>
      *
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/language/CSimpleExpression.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/language/CSimpleExpression.java
index d929a3ea0e44..13a1b14b0cf6 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/language/CSimpleExpression.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/language/CSimpleExpression.java
@@ -18,6 +18,7 @@ package org.apache.camel.model.language;
 
 import jakarta.xml.bind.annotation.XmlAccessType;
 import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlAttribute;
 import jakarta.xml.bind.annotation.XmlRootElement;
 import jakarta.xml.bind.annotation.XmlTransient;
 
@@ -31,11 +32,16 @@ import org.apache.camel.spi.Metadata;
 @XmlAccessorType(XmlAccessType.FIELD)
 public class CSimpleExpression extends TypedExpressionDefinition {
 
+    @XmlAttribute
+    @Metadata(defaultValue = "false", javaType = "java.lang.Boolean")
+    private String pretty;
+
     public CSimpleExpression() {
     }
 
     protected CSimpleExpression(CSimpleExpression source) {
         super(source);
+        this.pretty = source.pretty;
     }
 
     public CSimpleExpression(String expression) {
@@ -44,6 +50,7 @@ public class CSimpleExpression extends 
TypedExpressionDefinition {
 
     private CSimpleExpression(Builder builder) {
         super(builder);
+        this.pretty = builder.pretty;
     }
 
     @Override
@@ -56,12 +63,41 @@ public class CSimpleExpression extends 
TypedExpressionDefinition {
         return "csimple";
     }
 
+    public String getPretty() {
+        return pretty;
+    }
+
+    /**
+     * To pretty format the output (only JSon or XML supported)
+     */
+    public void setPretty(String pretty) {
+        this.pretty = pretty;
+    }
+
     /**
      * {@code Builder} is a specific builder for {@link CSimpleExpression}.
      */
     @XmlTransient
     public static class Builder extends AbstractBuilder<Builder, 
CSimpleExpression> {
 
+        private String pretty;
+
+        /**
+         * To pretty format the output (only JSon or XML supported)
+         */
+        public Builder pretty(String pretty) {
+            this.pretty = pretty;
+            return this;
+        }
+
+        /**
+         * To pretty format the output (only JSon or XML supported)
+         */
+        public Builder pretty(boolean pretty) {
+            this.pretty = Boolean.toString(pretty);
+            return this;
+        }
+
         @Override
         public CSimpleExpression end() {
             return new CSimpleExpression(this);
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/language/SimpleExpression.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/language/SimpleExpression.java
index f2f464ad73da..75f243052cd4 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/language/SimpleExpression.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/language/SimpleExpression.java
@@ -18,6 +18,7 @@ package org.apache.camel.model.language;
 
 import jakarta.xml.bind.annotation.XmlAccessType;
 import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlAttribute;
 import jakarta.xml.bind.annotation.XmlRootElement;
 import jakarta.xml.bind.annotation.XmlTransient;
 
@@ -32,11 +33,16 @@ import org.apache.camel.spi.Metadata;
 @XmlAccessorType(XmlAccessType.FIELD)
 public class SimpleExpression extends TypedExpressionDefinition {
 
+    @XmlAttribute
+    @Metadata(defaultValue = "false", javaType = "java.lang.Boolean")
+    private String pretty;
+
     public SimpleExpression() {
     }
 
     protected SimpleExpression(SimpleExpression source) {
         super(source);
+        this.pretty = source.pretty;
     }
 
     public SimpleExpression(String expression) {
@@ -49,6 +55,7 @@ public class SimpleExpression extends 
TypedExpressionDefinition {
 
     private SimpleExpression(Builder builder) {
         super(builder);
+        this.pretty = builder.pretty;
     }
 
     @Override
@@ -61,12 +68,41 @@ public class SimpleExpression extends 
TypedExpressionDefinition {
         return "simple";
     }
 
+    public String getPretty() {
+        return pretty;
+    }
+
+    /**
+     * To pretty format the output (only JSon or XML supported)
+     */
+    public void setPretty(String pretty) {
+        this.pretty = pretty;
+    }
+
     /**
      * {@code Builder} is a specific builder for {@link SimpleExpression}.
      */
     @XmlTransient
     public static class Builder extends AbstractBuilder<Builder, 
SimpleExpression> {
 
+        private String pretty;
+
+        /**
+         * To pretty format the output (only JSon or XML supported)
+         */
+        public Builder pretty(String pretty) {
+            this.pretty = pretty;
+            return this;
+        }
+
+        /**
+         * To pretty format the output (only JSon or XML supported)
+         */
+        public Builder pretty(boolean pretty) {
+            this.pretty = Boolean.toString(pretty);
+            return this;
+        }
+
         @Override
         public SimpleExpression end() {
             return new SimpleExpression(this);
diff --git 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/CSimpleExpressionReifier.java
 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/CSimpleExpressionReifier.java
index 68adfbff2bed..7cf64f4286f9 100644
--- 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/CSimpleExpressionReifier.java
+++ 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/CSimpleExpressionReifier.java
@@ -32,4 +32,13 @@ public class CSimpleExpressionReifier extends 
TypedExpressionReifier<CSimpleExpr
         return false;
     }
 
+    @Override
+    protected Object[] createProperties() {
+        Object[] properties = new Object[3];
+        properties[0] = asResultType();
+        properties[1] = parseBoolean(definition.getTrim());
+        properties[2] = parseBoolean(definition.getPretty());
+        return properties;
+    }
+
 }
diff --git 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/SimpleExpressionReifier.java
 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/SimpleExpressionReifier.java
index ca066c4d382a..577b05c68ce0 100644
--- 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/SimpleExpressionReifier.java
+++ 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/SimpleExpressionReifier.java
@@ -34,9 +34,10 @@ public class SimpleExpressionReifier extends 
TypedExpressionReifier<SimpleExpres
 
     @Override
     protected Object[] createProperties() {
-        Object[] properties = new Object[2];
+        Object[] properties = new Object[3];
         properties[0] = asResultType();
         properties[1] = parseBoolean(definition.getTrim());
+        properties[2] = parseBoolean(definition.getPretty());
         return properties;
     }
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePrettyTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePrettyTest.java
new file mode 100644
index 000000000000..99851279aa6f
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePrettyTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.simple;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+public class SimplePrettyTest extends ContextTestSupport {
+
+    private static final String XML = """
+            <person>
+              <name>
+                Jack
+              </name>
+            </person>""";
+
+    private static final String JSON = """
+            {
+               "name": "Jack",
+               "age": 44
+            }
+            """;
+
+    @Test
+    public void testPrettyXml() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived(XML);
+
+        template.sendBody("direct:xml", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testPrettyJSon() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived(JSON);
+
+        template.sendBody("direct:json", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testPrettyText() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:text", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:xml")
+                        
.setBody().simple("<person><name>Jack</name></person>", true)
+                        .to("mock:result");
+
+                from("direct:json")
+                        .setBody().simple("{ \"name\": \"Jack\", \"age\": 44 
}", true)
+                        .to("mock:result");
+
+                from("direct:text")
+                        .setBody().simple("Hello ${body}", true)
+                        .to("mock:result");
+            }
+        };
+    }
+}
diff --git 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 0dab43edf902..798fa6f1c2a6 100644
--- 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -2365,7 +2365,10 @@ public class ModelParser extends BaseParser {
         return doParse(new SpringTransactionErrorHandlerDefinition(), 
transactionErrorHandlerDefinitionAttributeHandler(), 
defaultErrorHandlerDefinitionElementHandler(), noValueHandler());
     }
     protected CSimpleExpression doParseCSimpleExpression() throws IOException, 
XmlPullParserException {
-        return doParse(new CSimpleExpression(), 
typedExpressionDefinitionAttributeHandler(), noElementHandler(), 
expressionDefinitionValueHandler());
+        return doParse(new CSimpleExpression(), (def, key, val) -> switch 
(key) {
+                case "pretty": def.setPretty(val); yield true;
+                default: yield 
typedExpressionDefinitionAttributeHandler().accept(def, key, val);
+            }, noElementHandler(), expressionDefinitionValueHandler());
     }
     protected <T extends TypedExpressionDefinition> AttributeHandler<T> 
typedExpressionDefinitionAttributeHandler() {
         return (def, key, val) -> switch (key) {
@@ -2461,7 +2464,10 @@ public class ModelParser extends BaseParser {
         return doParse(new RefExpression(), 
typedExpressionDefinitionAttributeHandler(), noElementHandler(), 
expressionDefinitionValueHandler());
     }
     protected SimpleExpression doParseSimpleExpression() throws IOException, 
XmlPullParserException {
-        return doParse(new SimpleExpression(), 
typedExpressionDefinitionAttributeHandler(), noElementHandler(), 
expressionDefinitionValueHandler());
+        return doParse(new SimpleExpression(), (def, key, val) -> switch (key) 
{
+                case "pretty": def.setPretty(val); yield true;
+                default: yield 
typedExpressionDefinitionAttributeHandler().accept(def, key, val);
+            }, noElementHandler(), expressionDefinitionValueHandler());
     }
     protected SpELExpression doParseSpELExpression() throws IOException, 
XmlPullParserException {
         return doParse(new SpELExpression(), 
typedExpressionDefinitionAttributeHandler(), noElementHandler(), 
expressionDefinitionValueHandler());
diff --git 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index 416a78326ecd..27b570663313 100644
--- 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++ 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -3096,6 +3096,7 @@ public class ModelWriter extends BaseWriter {
     protected void doWriteCSimpleExpression(String name, CSimpleExpression 
def) throws IOException {
         startElement(name);
         doWriteTypedExpressionDefinitionAttributes(def);
+        doWriteAttribute("pretty", def.getPretty(), "false");
         doWriteValue(def.getExpression());
         endElement(name);
     }
@@ -3242,6 +3243,7 @@ public class ModelWriter extends BaseWriter {
     protected void doWriteSimpleExpression(String name, SimpleExpression def) 
throws IOException {
         startElement(name);
         doWriteTypedExpressionDefinitionAttributes(def);
+        doWriteAttribute("pretty", def.getPretty(), "false");
         doWriteValue(def.getExpression());
         endElement(name);
     }
diff --git 
a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
 
b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
index 2addf34bb22d..022969a581da 100644
--- 
a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
+++ 
b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
@@ -3096,6 +3096,7 @@ public class ModelWriter extends BaseWriter {
     protected void doWriteCSimpleExpression(String name, CSimpleExpression 
def) throws IOException {
         startElement(name);
         doWriteTypedExpressionDefinitionAttributes(def);
+        doWriteAttribute("pretty", def.getPretty(), "false");
         doWriteValue(def.getExpression());
         endElement(name);
     }
@@ -3242,6 +3243,7 @@ public class ModelWriter extends BaseWriter {
     protected void doWriteSimpleExpression(String name, SimpleExpression def) 
throws IOException {
         startElement(name);
         doWriteTypedExpressionDefinitionAttributes(def);
+        doWriteAttribute("pretty", def.getPretty(), "false");
         doWriteValue(def.getExpression());
         endElement(name);
     }
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index fb3cf1a11ecc..55362f1523a5 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -1752,6 +1752,7 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
             properties = {
                     @YamlProperty(name = "expression", type = "string", 
required = true, description = "The expression value in your chosen language 
syntax", displayName = "Expression"),
                     @YamlProperty(name = "id", type = "string", description = 
"Sets the id of this node", displayName = "Id"),
+                    @YamlProperty(name = "pretty", type = "boolean", 
defaultValue = "false", description = "To pretty format the output (only JSon 
or XML supported)", displayName = "Pretty"),
                     @YamlProperty(name = "resultType", type = "string", 
description = "Sets the class of the result type (type from output)", 
displayName = "Result Type"),
                     @YamlProperty(name = "trim", type = "boolean", 
defaultValue = "true", description = "Whether to trim the value to remove 
leading and trailing whitespaces and line breaks", displayName = "Trim")
             }
@@ -1786,6 +1787,11 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
                     target.setId(val);
                     break;
                 }
+                case "pretty": {
+                    String val = asText(node);
+                    target.setPretty(val);
+                    break;
+                }
                 case "resultType": {
                     String val = asText(node);
                     target.setResultTypeName(val);
@@ -17654,6 +17660,7 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
             properties = {
                     @YamlProperty(name = "expression", type = "string", 
required = true, description = "The expression value in your chosen language 
syntax", displayName = "Expression"),
                     @YamlProperty(name = "id", type = "string", description = 
"Sets the id of this node", displayName = "Id"),
+                    @YamlProperty(name = "pretty", type = "boolean", 
defaultValue = "false", description = "To pretty format the output (only JSon 
or XML supported)", displayName = "Pretty"),
                     @YamlProperty(name = "resultType", type = "string", 
description = "Sets the class of the result type (type from output)", 
displayName = "Result Type"),
                     @YamlProperty(name = "trim", type = "boolean", 
defaultValue = "true", description = "Whether to trim the value to remove 
leading and trailing whitespaces and line breaks", displayName = "Trim")
             }
@@ -17688,6 +17695,11 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
                     target.setId(val);
                     break;
                 }
+                case "pretty": {
+                    String val = asText(node);
+                    target.setPretty(val);
+                    break;
+                }
                 case "resultType": {
                     String val = asText(node);
                     target.setResultTypeName(val);
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 9cfed89b85a4..55547c75d209 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -13866,6 +13866,12 @@
               "title" : "Id",
               "description" : "Sets the id of this node"
             },
+            "pretty" : {
+              "type" : "boolean",
+              "title" : "Pretty",
+              "description" : "To pretty format the output (only JSon or XML 
supported)",
+              "default" : false
+            },
             "resultType" : {
               "type" : "string",
               "title" : "Result Type",
@@ -14820,6 +14826,12 @@
               "title" : "Id",
               "description" : "Sets the id of this node"
             },
+            "pretty" : {
+              "type" : "boolean",
+              "title" : "Pretty",
+              "description" : "To pretty format the output (only JSon or XML 
supported)",
+              "default" : false
+            },
             "resultType" : {
               "type" : "string",
               "title" : "Result Type",
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/SimplePrettyTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/SimplePrettyTest.groovy
new file mode 100644
index 000000000000..570f22ae3d0e
--- /dev/null
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/SimplePrettyTest.groovy
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.yaml
+
+import org.apache.camel.component.mock.MockEndpoint
+import org.apache.camel.dsl.yaml.support.YamlTestSupport
+
+class SimplePrettyTest extends YamlTestSupport {
+
+    def "prettyXML"() {
+        setup:
+        loadRoutes '''
+                - route:
+                    from:
+                      uri: direct:xml
+                      steps:    
+                        - setBody:
+                            simple:
+                              expression: "<person><name>Jack</name></person>"
+                              pretty: true
+                        - to:
+                            uri: mock:result
+                        '''
+        withMock('mock:result') {
+            expectedMessageCount 1
+        }
+
+        when:
+        context.start()
+
+        withTemplate {
+            to('direct:xml').withBody('Hello World').send()
+        }
+
+        then:
+        MockEndpoint.assertIsSatisfied(context)
+    }
+
+    def "prettyJSon"() {
+        setup:
+        loadRoutes '''
+                - route:
+                    from:
+                      uri: direct:json
+                      steps:    
+                        - setBody:
+                            simple:
+                              expression: '"name": "Jack", "age": 44 }'
+                              pretty: true
+                        - to:
+                            uri: mock:result
+                        '''
+        withMock('mock:result') {
+            expectedMessageCount 1
+        }
+
+        when:
+        context.start()
+
+        withTemplate {
+            to('direct:json').withBody('Hello World').send()
+        }
+
+        then:
+        MockEndpoint.assertIsSatisfied(context)
+    }
+
+    def "prettyText"() {
+        setup:
+        loadRoutes '''
+                - route:
+                    from:
+                      uri: direct:text
+                      steps:    
+                        - setBody:
+                            simple:
+                              expression: 'Hello ${body}'
+                              pretty: true
+                        - to:
+                            uri: mock:result
+                        '''
+        withMock('mock:result') {
+            expectedBodiesReceived 'Hello World'
+        }
+
+        when:
+        context.start()
+
+        withTemplate {
+            to('direct:text').withBody('World').send()
+        }
+
+        then:
+        MockEndpoint.assertIsSatisfied(context)
+    }
+}

Reply via email to