Marshal

The Marshal EIP converts the internal format (objects or structures) into an external format (such as JSON or XML) for communication or storage. For example, it can transform a Java object into a JSON or XML representation.

Difference between Marshal and Unmarshal

Marshal and Unmarshal are fundamental processes for data manipulation, enabling interoperability between systems.

  • Marshal: this is the process of transforming data from Camel’s internal format into a standardized external format, such as JSON, XML, CSV, or others. This conversion is essential to integrate the flow with external systems, send messages to APIs, or store information in files in a structured way.

  • Unmarshal: this refers to the reverse process, where data received in an external format (e.g., JSON, XML, CSV) is converted into the internal format used by Camel. This step is necessary for messages to be processed, handled, or routed within Camel’s integration flow.

Examples

  • CSV

    • The message will be converted to csv.

    • No additional parameters are required.

- marshal:
    csv: {}
  • JSON

    • The message will be converted to json.

    • The Jackson library will be used to serialize the message body.

- marshal:
    json:
      library: Jackson
  • XML

    • The message will be converted to XML.

    • The jacksonXml format uses the Jackson library, but there is also a generic xml format.

- marshal:
    jacksonXml: {}
- marshal:
    xml: {}
Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]