Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Page

Table of Contents
maxLevel2
excludeAdditional Resources|Related Links|Related Information

decodeURIComponent

Description

Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent.

This is similar to the JavaScript decodeURIComponent.

Syntax


Code Block
decodeURIComponent(encodedURI)


Examples

Expression: decodeURIComponent($Encoded)

where $Encoded contains "Hello%2C+World%21"

Result: "Hello, World!"

encodeURIComponent

Description

Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by  the UTF-8 encoding of the character.

This is similar to the JavaScript encodeURIComponent.

Syntax


Code Block
encodeURIComponent(string)


Examples

Expression: encodeURIComponent('Hello, World!')

Result: "Hello%2C+World%21"


eval

Description

Evaluates the expression represented by the given string. The expression can reference document values and pipeline parameters.

This is similar to the JavaScript eval().

Note

Using eval() has a significant performance penalty and will slow down a pipeline when the document count increases. Most eval() use cases can be replaced with statically defined expressions, or with a dynamically generated expression library file.


Syntax


Code Block
eval(string)


Examples

Expression: eval(5+2)

Result: 7


Expression: eval(_id < 100)

Result: false (if the value of the pipeline parameter id is greater than 100)

false

Description

A Boolean literal

This is similar to the JavaScript Boolean literals.

instanceof

Description

Returns true if the given object is an instance of the given type.

This is similar to the JavaScript instanceof

Syntax


Code Block
object instanceof type

The possible values for the type are: Null, Boolean, String, Number, Object, Array, Date, LocalDate, DateTime, and LocalDateTime. 

Examples

Expression: {} instanceof Object

Result: true


Expression: 'foo' instanceof Object

Result: false


Expression: 'foo' instanceof String

Result: true

isNaN

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"

lib

DescriptionThe global variable that contains the imported expression libraries.
Syntaxlib.library.property(field)
Examples

lib.library.convertStatus($status)

where:

  • library is the name of the expression library file (.expr)
  • convertStatus is a property within that library
  • $status is a field to act on.

null

Description

A literal representing an empty value.

This is similar to the JavaScript null.

parseFloat

Description

Parses a string argument and returns a floating point number.

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

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

true

Description

A Boolean literal

This is similar to the JavaScript Boolean literals.

typeof

Description

Returns a string indicating the object type.

This is similar to the JavaScript typeof.

Syntax


Code Block
typeof item

The possible return values are: "boolean", "number", "string", "object", and "array".

Examples

Expression: typeof 'foo'

Result: string


Expression: typeof 42

Result: number


Expression: typeof true

Result: boolean


Expression: typeof $Array

where $Array contains an array

Result: array

...