A JSONata operator performs an operation on two values to produce a single result.

Fernhill SCADA supports these JSONata operators:

Operator | Priority | Description |
---|---|---|

Multiply (*) | 5 | Multiplies two numbers |

Divide (/) | 5 | Divides two numbers |

Modulus (%) | 5 | Returns the remainder when dividing two numbers |

Concatenate (&) | 4 | Concatenates two strings |

Add (+) | 4 | Adds two numbers |

Subtract (-) | 4 | Subtracts two numbers |

Equal (=) | 3 | Tests whether two values are equal |

Not Equal (!=) | 3 | Tests whether two values are not equal |

Greater Than (>) | 3 | Returns true if the left value is greater than the right value |

Greater Than or Equal to (>=) | 3 | Returns true if the left value is greater than or equal to the right value |

Less Than (<) | 3 | Returns true if the left value is less than the right value |

Less Than or Equal to (<=) | 3 | Returns true if the left value is less than or equal to the right value |

Logical AND (and) | 2 | Returns true if both the left and right values are true |

Logical OR (or) | 1 | Returns true if either left value is true, or the right value is true |

Note: When multiple operators are used in an expression, the operator priority determines the order of evaluation. Higher priority operators are evaluated before lower priority operators. Equal priority operators are evaluated left to right.

The multiply operator (*) adds the left and right operands to produce the numerical product. The left and right operands must be numbers. A runtime error will occur if either the left or the right operand are not numbers.

Examples

Operation | Result |
---|---|

12 * 5 | 60 |

10 * 0.5 | 5 |

The divide operator (/) divides the left operand by the right operand. The left and right operands must be numbers. A runtime error will occur if either the left or the right operand are not numbers. If the right operand is zero, the return value is null.

Examples

Operation | Result |
---|---|

12 / 5 | 2.4 |

10 / 0 | null |

The modulus operator (%) returns the remainder after dividing the left operand by the right operand. The left and right operands must be numbers. A runtime error will occur if either the left or the right operand are not numbers. If the right operand is zero, the return value is null.

Examples

Operation | Result |
---|---|

12 % 5 | 2 |

10 % 0 | null |

The concatenate operator (&) joins the left and right operands as strings. If either the left or right operand is not a string, it will be coerced to a string.

Examples

Operation | Result |
---|---|

"Value=" & 5 | "Value=5" |

The add operator (+) adds the left and right operands to produce the numerical sum. The left and right operands must be numbers. A runtime error will occur if either the left or the right operand are not numbers.

Examples

Operation | Result |
---|---|

12 + 5 | 17 |

10.5 + 11.1 | 21.6 |

The subtract operator (-) subtracts the right operand from the left operand to produce the numerical sum. The left and right operands must be numbers. A runtime error will occur if either the left or the right operand are not numbers.

Examples

Operation | Result |
---|---|

12 - 5 | 7 |

10.5 - 11.1 | -0.6 |

The equal operator (=) tests whether the left and right operands are the same type and value. If either the left operand, or the right operand, are invalid selectors, the operation returns false. If the left and right operands are different types, the operation returns false.

Examples

Operation | Result |
---|---|

null = null | true |

false = true | false |

false = false | true |

12 = 5 | false |

12 = 12 | true |

\"12\" = 12 | false |

The not equal operator (!=) tests whether the left and right operands are different types or different values. If either the left operand, or the right operand, are invalid selectors, the operation returns false. If the left and right operands are different types, the operation returns true.

Examples

Operation | Result |
---|---|

null != null | false |

false != true | true |

false != false | false |

12 != 5 | true |

12 != 12 | false |

\"12\" != 12 | true |

The greater than operator (>) returns true if the left operand is greater than the right operand. If either the left operand, or the right operand, are invalid selectors, the operation returns false. The left and right operands must be both numbers or both strings.

Examples

Operation | Result |
---|---|

12 > 5 | true |

12 > 12 | false |

12 > 17 | false |

\"This\" > \"That\" | true |

The greater than or equal to operator (>=) returns true if the left operand is greater than or equal to the right operand. If either the left operand, or the right operand, are invalid selectors, the operation returns false. The left and right operands must be both numbers or both strings.

Examples

Operation | Result |
---|---|

12 >= 5 | true |

12 >= 12 | true |

12 >= 17 | false |

\"This\" >= \"That\" | true |

The less than operator (<) returns true if the left operand is less than the right operand. If either the left operand, or the right operand, are invalid selectors, the operation returns false. The left and right operands must be both numbers or both strings.

Examples

Operation | Result |
---|---|

12 < 5 | false |

12 < 12 | false |

12 < 17 | true |

\"This\" < \"That\" | false |

The less than or equal to operator (<=) returns true if the left operand is less than or equal to the right operand. If either the left operand, or the right operand, are invalid selectors, the operation returns false. The left and right operands must be both numbers or both strings.

Examples

Operation | Result |
---|---|

12 <= 5 | false |

12 <= 12 | true |

12 <= 17 | true |

\"This\" <= \"That\" | false |

The Logical AND operator returns true if both the left and right values are true.

Examples

Operation | Result |
---|---|

false and false | false |

false and true | false |

true and false | false |

true and true | true |

1 and 0 | false |

1 and 1 | true |

The Logical OR operator returns true if either the left or right values are true.

Examples

Operation | Result |
---|---|

false or false | false |

false or true | true |

true or false | true |

true or true | true |

0 or 0 | false |

1 or 0 | true |

To learn more about the supported features of JSONata in Fernhill SCADA.

For the meaning of terms used in **Fernhill SCADA**.