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.


Example 1: Create a new object

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"]

If we want to create a new object, we can used the OBJECT.NEW:

OBJECT.NEW({{data.vin, data.vehicle}})

This return the following:

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

Example 2: 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, we could do so like this:

MAP(OBJECT.NEW({{"fleet_name", _}}), data.fleets)

This returns the following:

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