This article documents the JSON tasks available in CIC Studio for use in Business Processes. Here's a simple overview:
- JSON - Create – Initializes a new, empty JSON object.
- JSON - Read From Type – Converts a String or Storage Node into a JSON object.
- JSON - Get – Retrieves a value from the root of a JSON object by name.
- JSON - Get By Pointer – Fetches a specific value from anywhere in a JSON object (including nested arrays/objects) using a path-style "pointer" string, without needing to loop through the data.
- JSON - Set – Adds or sets a value at the root of a JSON object under a given name.
- JSON - To Dictionary – Converts a JSON object into a Dictionary data type.
- JSON - To List – Converts a JSON array into a List data type (errors if the JSON isn't an array).
- JSON - To Storage Node – Converts a JSON object into a Storage Node.
In short: these are building-block tasks for creating, reading, extracting, modifying, and converting JSON data within a Cleo Business Process workflow.
Video: See the Community video on using JSON tasks in a Business Process.
Examples
Here's a simple usage example for each JSON task:
| Task | Example Scenario | Example Inputs | Example Result |
|---|---|---|---|
| JSON - Create | Start a new JSON object to build up order data | (no input needed) |
JSON variable = {}
|
| JSON - Read From Type | Convert an API response string into JSON | Data to Read = "{\"id\":101,\"name\":\"Will\"}"
|
Result = JSON object {id:101, name:"Will"}
|
| JSON - Get | Get the customer's ID from the root of a JSON object | JSON = {"id":101,"name":"Will"}, Name = "id"
|
Result = 101
|
| JSON - Get By Pointer | Get a nested customer email without looping | JSON = {"customer":{"email":"wgeiger@cleo.com"}}, Pointer = /customer/email
|
Result = "wgeiger@cleo.com"
|
| JSON - Set | Add a new "status" field to an order JSON | JSON = {"id":101}, Name = "status", Value = "Shipped"
|
JSON becomes {"id":101,"status":"Shipped"}
|
| JSON - To Dictionary | Convert customer JSON into a Dictionary for use elsewhere in the BP | JSON = {"id":101,"name":"Will"}
|
Result = Dictionary with keys id, name
|
| JSON - To List | Convert a JSON array of order types into a List | JSON = ["PO","SO","ACK"]
|
Result = List ["PO","SO","ACK"]
|
| JSON - To Storage Node | Save a JSON object as a Storage Node file for downstream processing | JSON = {"id":101,"name":"Will"}
|
To Storage Node = file/node containing that JSON data |
JSON - Create
This task initializes a JSON variable or parameter as an empty JSON body.
| Parameter | Type | Description |
|---|---|---|
| JSON | JSON | The resulting JSON body. |
JSON - Read From Type
This task converts either a String or a Storage Node to a JSON object.
| Parameter | Type | Description |
|---|---|---|
| Result | JSON | The resulting JSON object. |
| Data to Read | String or Storage node | The source data to be converted to a JSON object. |
JSON - Get
This task gets an object (of type String, Long, Double Boolean, List, Dictionary, or JSON) from the root of the JSON object with the specified name.
| Parameter | Type | Description |
|---|---|---|
| JSON | JSON | The source JSON object. |
| Name | String | The name of the JSON object to be retrieved from the root of the source JSON object. |
| Result | <String, Long, Double, Boolean, List, Dictionary, or JSON> | The data with the specified name at the root of the JSON object. |
JSON - Get By Pointer
The task can be used to fetch a particular value of a key in a JSON or a JSONArray without having to loop through the JSON using the JSON-Get task.
The task accepts three Properties:
| Parameter | Type | Description |
|---|---|---|
| JSON | JSON, Storage Node & String | JSON input |
| Pointer | String | String of path to Key |
| Result | String, Long, Double, Boolean, List, Dictionary & JSON | Output |
JSON: This is the input JSON. The allowed datatypes are JSON, StorageNode, or String. While the datatype can be any of the above three, the data must be valid JSON.
Pointer: A pointer identifies the path to a certain key to access; this can be any string literal or string variable.
- The pointer starts with /
- Each segment is separated by /
- Each segment can be interpreted as either an array index or an object key.
- If we want to access the first element in order_type which is a JSON array we can use the index (index starts from zero).
Pointer: /customer/order_type/0In the given context, "customer" represents a JSON object, and "order_type" is a JSONArray that we wish to access. The "0" refers to the index of the specific element within that JSONArray.
Result: The result can be stored in the following datatypes: String, Long, Double, Boolean, List, Dictionary, or JSON.
Usage: Consider the following input JSON. If we want to access the value of the “email” key, here’s how the JSON Get By Pointer task could be used:
{
"id": 101,
"total_price_usd": "5.15",
"customer": {
"total_spent": "5.15",
"last_order_name": "#1050",
"last_order_id": 1012673151019,
"tax_exempt": false,
"created_at": "2018-03-08T16:04:34-05:00",
"last_name": "Geiger",
"verified_email": true,
"accepts_marketing_updated_at": "2018-12-31T11:06:21-05:00",
"tags": "password page, prospect",
"orders_count": 1,
"updated_at": "2019-04-09T14:53:13-04:00",
"accepts_marketing": true,
"admin_graphql_api_id": "gid://shopify/Customer/498608504875",
"currency": "USD",
"id": 498608504875,
“order_type”:[“PO”,”SO”,”ACK”],
"marketing_opt_in_level": "single_opt_in",
"state": "disabled",
"a/b": 1,
"first_name": "Will",
"email": "wgeiger@cleo.com"
}
}| Parameter | Type | Description |
|---|---|---|
| JSON | inputJSON | inputJSON, which can be stored in String, JSON, or StorageNode datatypes. |
| Pointer | /customer/email | The task fetches the value of “email” within the “customer” |
| Result | emailId | The result from the pointer /customer/email will be stored in the emailId variable. This can be String, Long, Double, Boolean, List, Dictionary, or JSON. |
Here’s another example: If the input JSON contains some special characters in the key...
{
"orders": ["bar", "baz"],
"": 0,
"sales/order": 1,
"c%d": 2,
"LastOrder^Name": “gieger”,
"g|h": 4,
"i\\j": 5,
"k\"l": 6,
" ": 7,
"m~n": 8
}...then the Pointers access the values as follows:
| Pointer | Result |
|---|---|
| /orders | ["bar", "baz"] |
| /orders/0 | “bar” |
| /” | 0 |
| /sales~1order | 1 |
| /c%d | 2 |
| /LastOrder^Name | gieger |
| /g|h | 4 |
| /i\j | 5 |
| /k"l | 6 |
| / | 7 |
| /m~0n | 8 |
Error Reporting and Troubleshooting
If the Pointer is syntactically wrong and is not available in the input JSON, the appropriate log message will appear in the Auditor Log.

If the input JSON is empty or syntactically wrong, an appropriate log message will appear in the Auditor Log.

If it is not able to convert the output based on the datatype given in the result, an appropriate error will be shown.

JSON - Set
This task sets an object (of type String, Long, Double Boolean, List, Dictionary, or JSON) in the root of the JSON object with the specified name.
| Parameter | Type | Description |
|---|---|---|
| JSON | JSON | The source JSON object that data will be added to. |
| Name | String | The name of the object to be set in the root of the source JSON object. |
| Value | <String, Long, Double, Boolean, List, Dictionary, or JSON> | The data to be set in the root of the source JSON object. |
JSON - To Dictionary
This task converts a JSON object to a dictionary
| Parameter | Type | Description |
|---|---|---|
| JSON | JSON | The source JSON object. |
| Result | Dictionary | The converted dictionary representation of the source JSON object. |
JSON - To List
This task converts a JSON object to a list. Assumes the JSON object being converted is a JSON array, otherwise a runtime exception will be thrown.
| Parameter |
Type |
Description |
|---|---|---|
| JSON | JSON | The source JSON object. |
| Result | List | The converted list representation of the source JSON object. |
JSON - To Storage Node
This task converts a JSON object to a Storage Node.
| Parameter | Type | Description |
|---|---|---|
| JSON | JSON | The source JSON object. |
| To Storage Node | Storage node | The storage node that contains the data from the source JSON object. |
Comments
0 comments
Please sign in to leave a comment.