logologo
Get Started
Guide
Development
Plugins
API
English
简体中文
Get Started
Guide
Development
Plugins
API
English
简体中文
logologo
Workflow
Overview
Getting Started

Triggers

Overview
Collection Event
Schedule
Pre-action Event
Post-action Event
Custom Action Event
Approval
Webhook

Nodes

Overview

AI

Large Language Model

Flow Control

Condition
Loop
Variables
Parallel Branch
Subflow
Output
Delay
End

Calculation

Calculation
Date Calculation
JSON Query
JSON Variable Mapping

Data Operations

Create Data
Update Data
Query Data
Delete Data
SQL Operation

Manual Processing

Manual Processing
Approval
CC

Extended Types

HTTP Request
JavaScript
Notification
Send Email
Response
Response Message
Variables
Execution History
Version Management
Advanced Options

Extension Development

Overview
Extending Trigger Types
Extending Node Types
API Reference
Previous PageDate Calculation
Next PageJSON Variable Mapping

#JSON Calculation

#Introduction

Based on different JSON calculation engines, it calculates or transforms complex JSON data generated by upstream nodes for use by subsequent nodes. For example, the results of SQL operation and HTTP request nodes can be transformed into the required values and variable formats through this node for use by subsequent nodes.

#Create Node

In the workflow configuration interface, click the plus ("+") button in the process to add a "JSON Calculation" node:

Create Node

Note

Usually, the JSON Calculation node is created below other data nodes to parse them.

#Node Configuration

#Parsing Engine

The JSON Calculation node supports different syntaxes through different parsing engines. You can choose based on your preferences and the features of each engine. Currently, three parsing engines are supported:

  • JMESPath
  • JSONPath Plus
  • JSONata

Engine Selection

#Data Source

The data source can be the result of an upstream node or a data object in the workflow context. It is usually a data object without a built-in structure, such as the result of an SQL node or an HTTP request node.

Data Source

Note

Usually, the data objects of collection-related nodes are structured through collection configuration information and generally do not need to be parsed by the JSON Calculation node.

#Parsing Expression

Custom parsing expressions based on parsing requirements and the chosen parsing engine.

Parsing Expression

Note

Different engines provide different parsing syntaxes. For details, please refer to the documentation in the links.

Since v1.0.0-alpha.15, expressions support variables. Variables are pre-parsed before the specific engine executes, replacing the variables with specific string values according to string template rules, and concatenating them with other static strings in the expression to form the final expression. This feature is very useful when you need to dynamically build expressions, for example, when some JSON content needs a dynamic key for parsing.

#Property Mapping

When the calculation result is an object (or an array of objects), you can further map the required properties to child variables through property mapping for use by subsequent nodes.

Property Mapping

Note

For an object (or array of objects) result, if property mapping is not performed, the entire object (or array of objects) will be saved as a single variable in the node's result, and the property values of the object cannot be used directly as variables.

#Example

Suppose the data to be parsed is from a preceding SQL node used to query data, and its result is a set of order data:

[
  {
    "id": 1,
    "products": [
      {
        "id": 1,
        "title": "Product 1",
        "price": 100,
        "quantity": 1
      },
      {
        "id": 2,
        "title": "Product 2",
        "price": 120,
        "quantity": 2
      }
    ]
  },
  {
    "id": 2,
    "products": [
      {
        "id": 3,
        "title": "Product 3",
        "price": 130,
        "quantity": 1
      },
      {
        "id": 4,
        "title": "Product 4",
        "price": 140,
        "quantity": 2
      }
    ]
  }
]

If we need to parse and calculate the total price of the two orders in the data, and assemble it with the corresponding order ID into an object to update the order's total price, we can configure it as follows:

Example - Parse SQL Configuration

  1. Select the JSONata parsing engine;
  2. Select the result of the SQL node as the data source;
  3. Use the JSONata expression $[0].{"id": id, "total": products.(price * quantity)} to parse;
  4. Select property mapping to map id and total to child variables;

The final parsing result is as follows:

[
  {
    "id": 1,
    "total": 340
  },
  {
    "id": 2,
    "total": 410
  }
]

Then, loop through the resulting order array to update the total price of the orders.

Update the total price of the corresponding order