Skip to main content

construct object

Construct a JSON object

Holly Conrad Smith avatar
Written by Holly Conrad Smith
Updated over a month ago

Category: Objects

Kind: Operation

Description: Construct an object

Inputs

Name

Abbreviation

Type

Access

Description

Existing

E

Object

Item

Existing object to add to

Data

D

Object

List

The data to add to the object, as a list of key-value pairs

Outputs

Name

Abbreviation

Type

Access

Description

Object

O

Object

Item

The constructed object

About

In JSON (JavaScript Object Notation), an object is a collection of key-value pairs.

It’s wrapped in curly braces { }, and each key-value pair inside it follows this format:

json CopyEdit "key": value

Example:

Here’s a JSON object representing a property listing:

json CopyEdit {   "address": "123 Maple Street",   "price": 450000,   "bedrooms": 3,   "bathrooms": 2,   "square_feet": 1800,   "status": "For Sale" }

Explanation:

  • The whole thing (inside the { }) is a JSON object.

  • It contains multiple key-value pairs:

    • "address" is the key, "123 Maple Street" is the value (a string).

    • "price" is the key, 450000 is the value (a number).

    • And so on.

Quick Facts About JSON Objects:

  • Keys must be strings, always in quotes.

  • Values can be strings, numbers, booleans, arrays, other objects, or null.

  • Pairs are separated by commas.

JSON Object vs JSON Array:

  • { ... } = object (key-value pairs)

  • [ ... ] = array (Lists of values or objects)

Example with Both:

json CopyEdit {   "listings": [     {       "address": "123 Maple Street",       "price": 450000     },     {       "address": "456 Oak Avenue",       "price": 525000     }   ] }
  • "listings" is a key.

  • The value is an array of objects, each representing a single real estate listing.

How-to

  1. Feed in an existing object.

    This could be from a panel or the result of another node

  2. Feed in a list of key-value pairs to add to the object

    This could be from a panel or the result of another node

  3. The result is the object and the key-value pairs wrapped as an object

Did this answer your question?