1. Home
  2. ...
  3. Data Formats
  4. JSON

JSON

See available data formats

The JSON (JavaScript Object Notation) format is one of the most widely used standards for data exchange between systems, especially in modern APIs and integrations. It allows structured information to be represented in a simple, readable way and is compatible with various programming languages.

In integration scenarios, it is common to transform JSON data into other formats, such as CSV, to facilitate consumption by spreadsheets or legacy systems. The example below shows how a flow can receive a JSON, process it, and generate a CSV file with the desired fields.

To process JSON data in integrations, we use specialized libraries that automate the conversion between JSON text and the system's internal structures. See the libraries available in Integrations:

  • Jackson: Widely used in Java, known for its performance and flexibility. It is the default library.
  • Gson: Simple and efficient, also for Java, developed by Google.
  • Fastjson: Focused on high performance, very popular in the Chinese Java ecosystem.
  • Johnzon: Lightweight implementation of the JSON-P/JSON-B specification for Java.
  • Jsonb: Standard Java API for object and JSON binding, based on the Jakarta EE specification.
TIPS

When to choose another library?
Prefer Jackson (default) for most cases. Use Gson if you already use Google APIs, Fastjson for high performance, Johnzon or Jsonb for projects that follow Jakarta EE standards.

Common error:
If the JSON is malformed or contains incompatible types, the conversion will fail. Always check the structure of the input data.

Example

The flow below receives a POST request containing a JSON and returns a CSV file with the selected headers.

The flow starts with a POST request containing JSON data in the body.

Input (JSON):

The Unmarshal EIP converts the JSON to Camel's internal structure.

The Marshal EIP converts the internal structure to CSV (external format).

  • Uses a semicolon to separate values (delimiter: ";")

  • And adds the headers firstName and lastName.

    Output (CSV):

How happy are you with this page?

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more