JSON to CSV Transformer (Deprecated)

Discover more about the JSON to CSV Transformer component and how to use it on the Digibee Integration Platform.

The JSON to CSV Transformer is deprecated and no longer updated. Please refer to the document with the most recent version of the feature: JSON to CSV V2.

JSON to CSV Transformer has the function of receiving a JSON object and, from it, generating an array with the data for the CSV already formatted.

Parameters

Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB).

The component waits for a message with the property "data" in the JSON. The value of this property can be an array or an object. See next a simple example that shows the functionality of JSON to CSV Transformer:

Messages flow

Input

You must configure an input JSON in a pipeline with the JSON to CSV Transformer component. After adding it to the pipeline, it's necessary to configure the headers as product,price or the example won't work.

{
   "data": [
       {
           "product": "Samsung 4k Q60T 55",
           "price": 3278.99
       },
       {
           "product": "Samsung galaxy S20 128GB",
           "price": 3698.99
       }
   ]
}

Output

With the configurations done according to the specifications above, the result will be:

{
   "data": [
       "Samsung 4k Q60T 55,3278.99",
       "Samsung galaxy S20 128GB,3698.99"
   ]
}

JSON to CSV Transformer in action

See below how the component responds to a situation and its specific configuration.

Informing a value as object with the configuration "Coalesce: false" and "Fail On Error: false"

With the pointed configurations, the JSON won't be processed and the result will be an error message with the property success: false

Input

{
   "data": [
       {
           "product": {
               "name": "Samsung 4k Q60T 55"
           },
           "price": 3278.99
       },
       {
           "product": {
               "name": "Samsung galaxy S20 128GB"
           },
           "price": 3698.99
       }
   ]
}

Output

{
   "success": false,
   "message": "Property product is an object"
}

Informing a value as object with the configuration "Coalesce: true" and "Fail On Error: false"

With the pointed configurations, the JSON will be processed and the result will be a csv with the object correctly treated.

Input

{
   "data": [
       {
           "product": {
               "name": "Samsung 4k Q60T 55"
           },
           "price": 3278.99
       },
       {
           "product": {
               "name": "Samsung galaxy S20 128GB"
           },
           "price": 3698.99
       }
   ]
}

Output

{
   "data": [
       "product,price",
       "\"{\"\"name\"\":\"\"Samsung 4k Q60T 55\"\"}\",3278.99",
       "\"{\"\"name\"\":\"\"Samsung galaxy S20 128GB\"\"}\",3698.99"
  ]
}

Informing a value as object with the configuration "Coalesce: false" and "Fail On Error: true"

With the pointed configurations, the JSON won't be processed and the deployment will be immediately interrupted.

Input

{
   "data": [
       {
           "product": {
               "name": "Samsung 4k Q60T 55"
           },
           "price": 3278.99
       },
       {
           "product": {
               "name": "Samsung galaxy S20 128GB"
          },
           "price": 3698.99
       }
   ]
}

Output

{
   "timestamp": 1603812645143,
   "error": "Property product is an object",
   "exception": "com.digibee.pipelineengine.exception.PipelineEngineRuntimeException",
   "code": 500
}

Last updated