JSONata Functions

JSONata Functions Introduction

A JSONata function performs an operation on one or more parameters, returning a single result.

Fernhill SCADA supports these JSONata functions:

FunctionDescription
$boolean(value) Casts the parameter to a boolean
$exists(value) Returns true if the value is defined
$not(value) Returns the inverse of the value parameter

$boolean(value)

The function $boolean(value) casts the value to a boolean using these rules:

ValueResult
nullfalse
Zerofalse
Non-zerotrue
Empty stringfalse
Non-empty stringtrue
Empty arrayfalse
Array with all false membersfalse
Array with any true membertrue
Empty objectfalse
Non-empty objecttrue

Examples

FunctionResult
$boolean(0)false
$boolean("0")true

$exists(value)

The function $exists(value) returns true if the value is defined.

Examples

The examples use this JSON document as a reference:

This sample JSON document is used by the selector examples:

{
  "Value": 23.5,
  "Units": "Volts",
}

FunctionResult
$exists(Description)false
$exists(Value)true
$exists(null)true
$exists(0)true
$exists(\"\")true

$not(value)

The function $not(value) returns true if the value is false, and returns false if the value is true.

Examples

FunctionResult
$not(true)false
$not(false)true
$not(null)true
$not(0)true
$not(1)false

Further Information

Fernhill SCADA JSONata

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

Glossary

For definitions of the terms used in Fernhill SCADA.