Overview

The Object Block creates an object from input values and a JSON template. It automatically escapes input values and inserts them into the template, supporting any data type as input and outputting an object.

Inputs

(Dynamic)
any

Input values to be inserted into the JSON template. Input names are dynamically generated from the JSON template based on values wrapped in double curly braces (e.g. {{input}}). Non-string inputs are automatically converted to strings.

Outputs

output
object | object[]

The object or array created from the input values and JSON template. The type will be object[] if the template defines an array, otherwise it will be object.

Editor Settings

jsonTemplate
code
default:"{ \"key\": \"{{input}}\" }"

The JSON template for creating the object. Input values are inserted into this template using double curly brace syntax (e.g. {{input}}). The template must be valid JSON.

Values wrapped in quotes (e.g. "{{input}}") will be treated as strings and escaped appropriately. Values without quotes will be inserted directly as JSON values.

width
number
default:200

The width of the block in pixels.

hidden
boolean
default:true

Whether the block is hidden in the block menu.

Example: Creating an object from multiple inputs

  1. Add an Object Block and set the JSON Template to:
    {
      "name": "{{name}}",
      "age": {{age}},
      "job": "{{job}}"
    }
    
  2. Add two Text Blocks with values “John Doe” and “Engineer”. Connect to name and job inputs.
  3. Add a Number Block with value 30. Connect to age input.
  4. Run the flow. The Object Block output will be:
    {
      "name": "John Doe",
      "age": 30,
      "job": "Engineer"
    }
    

Error Handling

The Object Block will error if:

  • The JSON Template is not a valid JSON string
  • The interpolated JSON string (after inserting input values) is not valid JSON

FAQ

See Also