OBJECT.NEW generates a new Object from a collection of key/value pairs. If the same key is present multiple times, the rightmost value will be used.

Function category: Object‚Äč






Collection of key/value pairs

arg1 can also contain a dynamic reference to the current data context, which is accessed with the _ character.


Let's say we're given a response with the following vehicle performance information.

{ "data": {
"vin": "3VWJP7AT9CM624721",
"vehicle": {
"fuel_efficiency": 95,
"breaking_time": 2400
"fleets": ["alpha", "bravo", "charlie"]

Example 1: Create a new object

If we want to create a new object, use the following function:

# Create a new object
OBJECT.NEW({ { 'vin', data.vin }, { 'fleets', COUNT(data.fleets) } })

Please note that the collection of key/value pairs has to be an array of arrays, i.e. like this:{{k1, v1}, {k2, v2}, ...}

This returns the following:

{ "vin": "3VWJP7AT9CM624721", "fleets": 3 }

Example 2: Create new object with dynamic keys

We can also use references as keys to create an object with keys based on data we have. For instance if you'd want to use the vin as the key you'd use something like this:

# Use the vin as key for our new object
OBJECT.NEW({{data.vin, data.vehicle}})

This returns the following:

{ "3VWJP7AT9CM624721": { "fuel_efficiency": 95, "breaking_time": 2400 } }

Example 3: Using the dynamic reference character ( _ )

It is also possible to employ the dynamic reference character (_) in using OBJECT.NEW. For instance, if we wanted to parse the fleet names into an array of objects, use the following function.

# Parse into an array using the dynamic reference
MAP(OBJECT.NEW({{"fleet_name", _}}), data.fleets)

This returns the following:

{ "fleet_name": "alpha" },
{ "fleet_name": "bravo" },
{ "fleet_name": "charlie" }