JSON Unroll

Most recent version: v0.0.1

See the changelog of this Action type here.

Overview

The JSON Unroll Action unrolls (explodes) an array of objects into individual events, while also inheriting top-level fields.

Ports

These are the input and output ports of this Action:

Input ports
  • Default port - All the events to be processed by this Action enter through this port.

Output ports
  • Default port - Events are sent through this port if no error occurs while processing them.

  • Error port - Events are sent through this port if an error occurs while processing them.

  • Unroll port - This port will output the unrolled array values.

Configuration

1

Find JSON Unroll in the Actions tab (under the Transformation group) and drag it onto the canvas.

2

To open the configuration, click the Action in the canvas and select Configuration.

3

Enter the required parameters:

Parameter
Description

Field to transform*

Select the JSON input event that holds the array to be unrolled.

Path*

Inidicate the JSON array name you want to unroll.

Output field*

The name that the exploded array element will receive in each new event.

4

Click Save to complete the process.

Example

Suppose you wish to unroll a JSON that comes in an input value called JSONdata

1

Input JSON

Your input data contains the following raw JSON file:

{
  "timestamp": "2024-03-18T12:45:00Z",
  "user": "Alice",
  "allPurchases": [
    {
      "item": "Laptop",
      "price": 1200,
      "payment_method": "Credit Card"
    },
    {
      "item": "Headphones",
      "price": 150,
      "payment_method": "PayPal"
    },
    {
      "item": "Smartphone",
      "price": 900,
      "payment_method": "Debit Card"
    }
  ]
}
2

Configuration

Add the JSON Unroll Action to the canvas and enter the following:

Parameter
Value

Field to transform

Select the JSONdata field.

Path

We need to unroll the array allPurchases.

Output field

We'll name the new field with the unrolled array purchases.

3

Result

These will be the output events. Each element under the original allPurchases array is now placed in a purchases field in its event:

Event 1:
{"JSONdata":"{"timestamp":"2024-03-18T12:45:00Z","user":"Alice","purchases":{"item":"Laptop","price":"1200","payment_method":"Credit Card"}

Event 2:
{""JSONdata":"{"timestamp":"2024-03-18T12:45:00Z","user":"Alice","purchases":{"item":"Headphones","price":"150","payment_method":"Paypal"}

Event 3:
{""JSONdata":"{"timestamp":"2024-03-18T12:45:00Z","user":"Alice","purchases":{"item":"Smartphone","price":"900","payment_method":"Smartphone"}

Last updated

Was this helpful?