Evaluate Expression
Evaluates a boolean expression and optionally returns the result with variable substitutions. Supports Boolean expression parsing with AND, OR, and NOT operators.
Request
GET /nxt?requestType=evaluateExpression&expression=<expr>&evaluate=<boolean>&vars=<var1>&vars=<var2>&values=<val1>&values=<val2>
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
expression | string | Conditional | Boolean expression to evaluate. |
evaluate | boolean | No | If true, evaluates the expression with the provided variable values. |
vars | string[] | Conditional | Variable names (required if evaluate = true). May be repeated. |
values | string[] | Conditional | Variable values (TRUE or FALSE). Must correspond 1:1 with vars. May be repeated. |
Response
With evaluate = true
{
"result": true,
"variables": ["A", "B", "C"],
"literalsCount": 3
}
With evaluate = false
{
"variables": ["A", "B", "C"],
"literalsCount": 3
}
Response Fields
| Field | Type | Description |
|---|---|---|
result | boolean | Result of the expression evaluation (only present if evaluate = true). |
variables | array of strings | Variables extracted from the expression. |
literalsCount | integer | Number of literals in the expression. |
Error Responses
| Condition | Response |
|---|---|
vars and values count mismatch | {"error": "Vars undefined or number of vars differs from number of values"} |
| Invalid boolean value | {"error": "<value> does not represent a valid boolean value..."} |
| Expression syntax error | Boolean expression error response |
Notes
- This endpoint does not require the blockchain to be running (
requireBlockchain = false). - Not chain-specific.
- Does not require admin password authentication (
requirePassword = false).
Source: EvaluateExpression.java.
Example
curl "http://localhost:22024/nxt?requestType=evaluateExpression&expression=A%20AND%20B&evaluate=true&vars=A&vars=B&values=TRUE&values=FALSE"