Skip to main content
Version: 1.28 (Current)

Create JSON Object

Audience: Low-code Engineers

Skill Prerequisites: Actions, Tokens, JSON

Builds a JSON object from a list of properties and saves it in a token. Each property has a name, a value and a type. The type decides how the value is written: as a string, a number, a boolean, a piece of JSON, or a list or object built with other actions.

String values are escaped for you, so quotes and line breaks in a token value don't break the JSON.

Typical Use Cases​

  • Build the JSON body of a Server Request from form values or tokens
  • Send real numbers and booleans to an API that doesn't accept them as strings
  • Turn a list into a JSON array inside an object, for example {"orderId": 1001, "lines": [...]}
  • Build nested JSON from objects made with Create Object

Don't use it to​

Action NameDescription
Create ObjectCreates an object, which the List Object type turns into a nested JSON object.
Add List EntryAdds entries to a list, which the List type turns into a JSON array.
List to JSONTurns a list into a JSON array.
Context to JSON ObjectSaves the tokens of the context as a JSON object.
Parse JSON Into TokensDoes the opposite: turns JSON into tokens.
Server RequestSends the JSON to an API.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
JSON PropertiesThe properties of the JSON object, one per row, in the order they're written. Each row has a Name, for example email, a Value, for example [Email], and a TypeFormatter. See Property types. All three columns support tokens.YesemptyNo

Output Parameters Reference​

ParameterDescriptionSupports TokensDefaultRequired
Output Token NameThe token that receives the JSON, for example RequestBody for [RequestBody]. If it's empty, the action does nothing.Noempty stringYes

Property types​

Choose a type for every row. If the type is empty, the action fails.

TypeFormatterValueIn JSON
StringAny text, for example [FirstName] [LastName].A string. Quotes, backslashes and line breaks are escaped: He said "hi" becomes "He said \"hi\"".
NumberA JSON number, for example 42, 19.99 or 1e3. Use a dot as the decimal separator.A number, for example 42. Trailing zeros are dropped: 12.50 becomes 12.5.
Booltrue or false, in any case, for example True.true or false.
JSONObjectA JSON object, for example {"city": "Denver"} or a token that holds one.The object, nested as it is.
JSONArrayA JSON array, for example ["red", "green"] or a token that holds one.The array, nested as it is.
ListThe name of a list, for example LinesList. List names are case-sensitive.An array, with one JSON object per list entry. List and object properties of the entries are expanded into nested arrays and objects.
List ObjectThe name of an object made with Create Object, for example Customer.A nested JSON object. Its list and object properties are expanded too.

For example, these rows:

NameValueTypeFormatter
nameJane "JD" DoeString
age34Number
subscribedTrueBool
address{"city": "Denver"}JSONObject
tags["vip", "newsletter"]JSONArray

give this JSON, on one line:

{"name":"Jane \"JD\" Doe","age":34,"subscribed":true,"address":{"city":"Denver"},"tags":["vip","newsletter"]}

List and List Object values​

  • Values keep their types. Numbers, booleans and dates are written as JSON numbers, booleans and ISO dates when the list holds them that way, for example a list from Create List from SQL. Lists that hold text, such as lists from Create List from JSON, give strings. Properties of Create Object objects are always strings.
  • Property names come from the list's properties. See Add List Entry for how they're set.
  • Missing lists or objects fail the action with Could not find the specified entity list. or Could not find the specified entity item.
  • Loops. If a list or object points back to itself, the action fails with an "infinite loop" error.

Considerations​

  • Always choose a type. A row without a type fails the action, even for plain text. Use String for text.
  • Tokens in JSONObject and JSONArray values aren't escaped. The value is read as JSON after the tokens are replaced. A token that holds JSON, such as [OrderResponse], works well. But if you type JSON around a token, for example {"name": "[Name]"}, a quote in the token value breaks it. Add each value as its own String row, or build the nested object with Create Object and the List Object type.
  • Invalid values fail the action. For example abc with Number, yes with Bool, or an array with JSONObject. The error names the property and the value, for example The value "abc" of property "age" is not valid for a JSON property value. or Failed to create JSON object at key="age" and value="abc". Could not convert value to int or float. An empty value fails for every type except String.
  • Watch number formats. Numbers with a leading zero, such as 012, are read as octal and give 10. Values such as 0x1F are read as hexadecimal. For codes, phone numbers or IDs with leading zeros, use String.
  • Names are used as they are. Dots don't create nested objects: customer.email is one property with a dot in its name. To nest, use JSONObject or List Object.
  • Names must be unique. Two rows with the same name, after tokens are replaced, fail the action. Names are case-sensitive, so id and Id are two properties.
  • Output. The JSON is written on one line, with the properties in the order of the rows. With no rows, the token holds {}. An existing token with the same name is overwritten.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Build the body of an API request​

This action builds a JSON body from form values and saves it in the RequestBody token, for example {"email":"jane@example.com","quantity":3,"giftWrap":false,"tags":["web","promo"]}. A Server Request can then send [RequestBody].

{
"Title": "Create JSON Object",
"ActionType": "CreateJsonObject",
"Description": "Build the order request body",
"Parameters": {
"Properties": [
{
"Name": "email",
"Value": "[Email]",
"TypeValidation": "String"
},
{
"Name": "quantity",
"Value": "[Quantity]",
"TypeValidation": "Number"
},
{
"Name": "giftWrap",
"Value": "[GiftWrap]",
"TypeValidation": "Bool"
},
{
"Name": "tags",
"Value": "[\"web\", \"promo\"]",
"TypeValidation": "JSONArray"
}
],
"OutputTokenName": "RequestBody"
}
}

[Quantity] must hold a number and [GiftWrap] must hold true or false, or the action fails.

2. Add a list as an array​

This action writes an order number and the entries of the LinesList list, built earlier with Add List Entry, to the OrderJson token.

{
"Title": "Create JSON Object",
"ActionType": "CreateJsonObject",
"Description": "Write the order with its lines",
"Parameters": {
"Properties": [
{
"Name": "orderNumber",
"Value": "[OrderNumber]",
"TypeValidation": "String"
},
{
"Name": "lines",
"Value": "LinesList",
"TypeValidation": "EntityList"
}
],
"OutputTokenName": "OrderJson"
}
}

If LinesList has entries with sku and quantity properties, [OrderJson] looks like this:

{"orderNumber":"SO-1001","lines":[{"sku":"A-100","quantity":"2"},{"sku":"B-200","quantity":"1"}]}

For a nested object, use the List Object type ("TypeValidation": "EntityObject") with the name of an object. See Create Object for a full example.

Revised 09/27/2026