Expression Operators
Overview
Expression types include Simple Expression, JSONPath, and XPath. In the Routing, Variable Assignment, Splitter, and Filter components, you can select an expression type for data processing.
Operator Description
- A simple expression can reference system data and attribute data.
Table 1 System data and attribute data Data Type
Data Source
Reference Mode
System data
Request body used by an external system to call an open API
${body}
Query results of the data source
Response body of the HTTP Client component calling result
Attribute data
Request parameters (including parameters of the Header, Query, and Path types) created in the Open API component
${property.Variable name}
Variable created in the Variable Assignment component
Response header parameters for the HTTP Client component to call the API
- JSONPath and XPath expressions are used to parse the request body or response body of the API in system data.
- If the system data to be parsed is in JSON format, use the JSONPath expression.
- If the system data to be parsed is in XML format, use the XPath expression.
Example:
- If the request body or response body of system data is as follows, you can use the JSONPath expression $.id to obtain the value of id.
{ "id": 1, "name": "test_user" } - If the request body or response body of system data is as follows, you can use the JSONPath expression $[1].name to obtain test_user02.
[ { "id": 1, "name": "test_user01" }, { "id": 2, "name": "test_user02" } ] - If the request body or response body of system data is as follows, you can obtain the value of title through XPath expression /bookstore/book/title/text().
<?xml version="1.0" encoding="UTF-8"?> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>30.00</price> </book> </bookstore>
- If the request body or response body of system data is as follows, you can use the JSONPath expression $.id to obtain the value of id.
Simple Expression Operators
The following table lists the supported relational operators.
|
Relational Operator |
Description |
|---|---|
|
== |
Determines whether the left value is equal to the right value, for example, ${property.name} == 'test'. |
|
=~ |
Case-insensitive and determines whether the character string on the left is the same as that on the right, for example, ${property.name} =~ 'TEST'. |
|
!= |
Determines whether the value on the left is different from that on the right, for example, ${property.name} != 'test'. |
|
!=~ |
Case-insensitive and determines whether the character string on the left is equal to that on the right, for example, ${property.name} !=~ 'TEST'. |
|
> |
Determines whether the value on the left is greater than that on the right, for example, ${property.num} > 1. |
|
>= |
Determines whether the value on the left is greater than or equal to the value on the right, for example, ${property.num} >= 1. |
|
< |
Determines whether the value on the left is less than that on the right, for example, ${property.num} < 1. |
|
<= |
Determines whether the value on the left is less than or equal to the value on the right, for example, ${property.num} <= 1. |
|
contains |
Determines whether the character string on the left contains the character string on the right, for example, ${property.name} contains'test'. |
|
!contains |
Determines whether the character string on the left does not contain the character string on the right, for example, ${property.name}!. contains'test'. |
|
~~ |
Case-insensitive and determines whether the character string on the left contains the character string on the right, for example, ${property.name} ~~'TEST'. |
|
!~~ |
Case-insensitive and determines whether the character string on the left contains the character string on the right, for example, ${property.name} !~~ 'TEST'. |
|
regex |
Determines whether the value on the left matches the regular expression on the right, for example, ${property.num} regex '\\d{4}'. |
|
!regex |
Determines whether the value on the left does not match the regular expression on the right, for example, ${property.num} !regex '\\d{4}'. |
|
in |
Determines whether the value on the left is in the set on the right. Elements in the set are separated by commas (,), for example, ${property.num} in '1,2,3'. |
|
!in |
Determines whether the value on the left is not in the set on the right. Elements in the set are separated by commas (,), for example, ${property.num} !in '1,2,3'. |
|
is |
Determines whether the type of the object on the left is the type on the right, for example, ${property.name} is 'String'. |
|
!is |
Determines whether the type of the object on the left is not the type on the right, for example, ${property.name} !is 'String'. |
|
startsWith |
Determines whether the character string on the left starts with the character string on the right, for example, ${property.name} startsWith 'test'. |
|
endsWith |
Determines whether the character string on the left ends with the character string on the right, for example, ${property.name} endsWith 'test'. |
The following table lists the supported logical operators.
|
Logical Operator |
Description |
|---|---|
|
&& |
And, for example, ${property.name} == 'test' && ${property.num} == 1 |
|
|| |
Or, for example, ${property.name} == 'test' || ${property.num} == 1 |
Last Article: Data Reference
Next Article: Increasing Resource Quota
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.