Create JSON Object
Audience:
Low-code EngineersSkill 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
- Save all the tokens of the context as JSON. Use Context to JSON Object instead.
- Turn a list into a top-level JSON array. Use List to JSON instead.
- Read values from JSON. Use Parse JSON Into Tokens instead.
Related Actions
| Action Name | Description |
|---|---|
| Create Object | Creates an object, which the List Object type turns into a nested JSON object. |
| Add List Entry | Adds entries to a list, which the List type turns into a JSON array. |
| List to JSON | Turns a list into a JSON array. |
| Context to JSON Object | Saves the tokens of the context as a JSON object. |
| Parse JSON Into Tokens | Does the opposite: turns JSON into tokens. |
| Server Request | Sends the JSON to an API. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| JSON Properties | The 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. | Yes | empty | No |
Output Parameters Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Output Token Name | The token that receives the JSON, for example RequestBody for [RequestBody]. If it's empty, the action does nothing. | No | empty string | Yes |
Property types
Choose a type for every row. If the type is empty, the action fails.
| TypeFormatter | Value | In JSON |
|---|---|---|
String | Any text, for example [FirstName] [LastName]. | A string. Quotes, backslashes and line breaks are escaped: He said "hi" becomes "He said \"hi\"". |
Number | A 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. |
Bool | true or false, in any case, for example True. | true or false. |
JSONObject | A JSON object, for example {"city": "Denver"} or a token that holds one. | The object, nested as it is. |
JSONArray | A JSON array, for example ["red", "green"] or a token that holds one. | The array, nested as it is. |
List | The 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 Object | The 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:
| Name | Value | TypeFormatter |
|---|---|---|
name | Jane "JD" Doe | String |
age | 34 | Number |
subscribed | True | Bool |
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.orCould 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
Stringfor 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 ownStringrow, or build the nested object with Create Object and theList Objecttype. - Invalid values fail the action. For example
abcwithNumber,yeswithBool, or an array withJSONObject. The error names the property and the value, for exampleThe value "abc" of property "age" is not valid for a JSON property value.orFailed 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 exceptString. - Watch number formats. Numbers with a leading zero, such as
012, are read as octal and give10. Values such as0x1Fare read as hexadecimal. For codes, phone numbers or IDs with leading zeros, useString. - Names are used as they are. Dots don't create nested objects:
customer.emailis one property with a dot in its name. To nest, useJSONObjectorList Object. - Names must be unique. Two rows with the same name, after tokens are replaced, fail the action. Names are case-sensitive, so
idandIdare 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
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