YAML

YAML is a Data Format to marshal and unmarshal Java objects to and from YAML.

For YAML to object marshalling, Camel provides integration with three popular YAML libraries:

Every library requires adding the special camel component (see "Dependency..." paragraphs further down). By default Camel uses the SnakeYAML library.

Using YAML data format with the SnakeYAML library

Using YAML in Spring DSL

When using Data Format in Spring DSL you need to declare the data formats first. This is done in the DataFormats XML tag.

And then you can refer to this id in the route:

 

Options for SnakeYAML Data Format

Name

Type

Default

Description

unmarshalType

Class

Object.class

Class of the object to be created
classLoader
ClassLoadernullThe classloader to use to instantiate objects
constructor
StringnullA reference to an
org.yaml.snakeyaml.constructor.BaseConstructor instance in the registry
representer
StringnullA reference to an
org.yaml.snakeyaml.representer.Representer instance in the registry
dumperOptions
StringnullA reference to an
org.yaml.snakeyaml.DumperOptions instance in the
registry
resolver
StringnullA reference to an
org.yaml.snakeyaml.resolver.Resolver instance in the registry
 
useApplicationContextClassLoader
 Booleantrue To use CamelContext's  
ApplicationContextClassLoader if no custom class loader is set and
ApplicationContextClassLoader is provided
prettyFlow
 Booleanfalse 
Force the emitter to produce a pretty YAML document when using the flow style

 

Dependencies for SnakeYAML

To use YAML in your camel routes you need to add the a dependency on camel-snakeyaml which implements this data format.

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).

 

 

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram