Object / JSON Nodes

> Build and manipulate structured data -- create objects, read and write typed fields, parse and stringify JSON, and merge objects together.

Object nodes work with the object pin type. In Brickr, objects are key-value containers with named properties, similar to JSON objects. The type system supports typed objects through structures, which define the shape and types of an object's properties.

You can define structures in the Types section of the Dashboard. Once created, they appear as options throughout the Builder wherever object types are used.

Creating Objects

create-json-object

Creates a new empty JSON object.

| Pin | Direction | Type | |-----|-----------|------| | object | Output | object |

combine-object

Creates a new object from individual key-value inputs. Displayed as Make Object in the Builder. The node has dynamic inputs -- add properties as needed, specifying a key name and value for each.

| Pin | Direction | Type | |-----|-----------|------| | key_0 | Input | string (property name) | | value_0 | Input | any | | key_1 | Input | string (property name) | | value_1 | Input | any | | ... | | | | object | Output | object |

When you assign a structure to the output, the node automatically creates input pins matching the structure's properties. This is the easiest way to build a typed object.

split-object

Breaks an object into its individual properties, exposing each as a separate output pin.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | property_0 | Output | (type of property) | | property_1 | Output | (type of property) | | ... | | |

When wired with a typed object (object:StructName), the output pins are automatically created based on the structure definition.

Setting Fields

These nodes return a new object with the specified field set to the given value. Each is typed to a specific value type for type safety.

set-string-field

Sets a string property on an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Input | string | | result | Output | object |

set-number-field

Sets a number property on an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Input | number | | result | Output | object |

set-bool-field

Sets a boolean property on an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Input | boolean | | result | Output | object |

set-object-field

Sets a nested object property on an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Input | object | | result | Output | object |

set-array-field

Sets an array property on an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Input | array | | result | Output | object |

Object nodes do not mutate the original object. They always return a new object with the changes applied. This makes it safe to use the same object in multiple branches of your flow.

Getting Fields

These nodes retrieve a typed value from an object by key name.

get-string-field

Retrieves a string property from an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Output | string |

get-number-field

Retrieves a number property from an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Output | number |

get-bool-field

Retrieves a boolean property from an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Output | boolean |

get-object-field

Retrieves a nested object property from an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Output | object |

get-array-field

Retrieves an array property from an object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | key | Input | string | | value | Output | array |

Use the typed get/set field nodes instead of generic property access whenever possible. They provide better type safety and help the editor validate your connections.

Inspecting Objects

extract-object-keys

Returns an array of all property names in the object.

| Pin | Direction | Type | |-----|-----------|------| | object | Input | object | | keys | Output | string:array |

JSON Operations

parse-json

Parses a JSON string into a structured value (object or array).

| Pin | Direction | Type | |-----|-----------|------| | value | Input | string | | result | Output | any |

The parse-json node will produce an error if the input string is not valid JSON. Use it with data you trust, or add error handling around it.

stringify-json

Converts a value to its JSON string representation.

| Pin | Direction | Type | |-----|-----------|------| | value | Input | any | | result | Output | string |

merge-json

Merges two objects into one. If both objects have a property with the same key, the value from the second object takes precedence.

| Pin | Direction | Type | |-----|-----------|------| | a | Input | object | | b | Input | object | | result | Output | object |

Use merge-json to apply default values. Put your defaults in a and the user-provided data in b. Any properties the user provides will override the defaults, while missing properties keep their default values.

sort-array-items

Sorts an array of items by a specified field.

| Pin | Direction | Type | |-----|-----------|------| | array | Input | any:array | | key | Input | string | | direction | Input | string | | result | Output | any:array |