Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: SWAT-2958

In this Page

...

Description

Determines whether a value is Not-a-Number (NaN) or not.

This is similar to the JavaScript isNaN.

Syntax


Code Block
isNaN(value)


Examples

Expression: isNaN(42)

Result: false


Expression: isNaN('a')

Result: true


Expression: isNaN('')

Result: false
The empty string is converted to 0 which is not NaN.

jsonPath

Description

Reads the values from the given object that match the given JSONPath. If the path is simple and does not traverse multiple paths through the object hierarchy (such as $parent.child.value), the value will be returned directly or an error will be raised if the path was not found. If the given path branches to cover multiple parts of the object hierarchy (such as $..array), an array will be returned, which may be empty if there were no matches.

Note

This return value of this function is slightly different from the one described here. Instead of returning false if a path is not found, an error will be raised.


Syntax


Code Block
jsonPath(obj, path)


Examples

Expression: This expression will return the "email_address" field in the array of objects at "$SupportTicketDefinition.partners" where the objects have a "type" property with a value of "contact".

Code Block
jsonPath($, "$SupportTicketDefinition.partners[?(value.type=='contact')].email_address")[0]

Where "$" contains:

Code Block
{
  "SupportTicketDefinition": {
    "partners": [
      {
        "type": "contact",
        "email_address": "bob@example.com"
      },
      {
        "type": "emergency",
        "email_address": "alice@example.com"
      }
    ]
  }
}

Result: "bob@example.com"

...

Description

Parses a string argument and returns a floating point number. Specifically, this function parses characters into a valid floating-point number left to right. Once a character breaks this condition (like a comma), then the parseFloat function considers the break as the end of the number, and the rest of the string is ignored (see last example).

This is similar to the JavaScript parseFloat.

Syntax


Code Block
parseFloat(string)


Examples

Expression: parseFloat("3.14e-2")

Result: 0.0314


Expression: parseFloat("id")

Result: NaN


Expression: parseFloat($field021).toFixed(4)

where $field021 contains "23.536269999999998"

Note

toFixed() will format this as a string, not a number.

Result: 23.5363


ExpressionparseFloat("3,145")

Result: 3

parseInt

Description

Parses a string argument and returns an integer.

This is similar to the JavaScript parseInt.

Pixels are not currently supported.

Syntax


Code Block
parseInt(string,radix)


Examples

Expression: parseInt(_id)

where _id has a value of "101"

Result: 101

...