Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated for SWAT-1072

Table of Contents

Object Examples

...

Expression


Code Block
$.hasOwnProperty('query.fred') ? $query.fred : 'not present in input'


DescriptionThis example is one way of doing an if-then-else expression.
Example

For example, to set a default pipeline variable in a document object, if you use the following expression for a mapper variable $lastname:

$.hasOwnProperty('lastname') ? $lastname : _lastname

$lastname has the value of $lastname as supplied by a document in the stream. If there is no document input, then $lastname is set to the _lastnameparameter value.


String Examples

Checking for a Non-empty String

...

Expression


Code Block
$.hasOwnProperty('customer.lastname') || 'default'


DescriptionThe expression verifies if $customer.lastname exists in the input document. If it does, then it applies its value to the target path, otherwise it applies 'default' . It returns True if $customer.lastname exists, else it shows 'default' as a string and applies it to the target path. 

Checking for a Non-empty String and an Existing Value

...