{% for i in [1, 2, 3] %}
{{ loop | check_type }}
{% endfor %}
Return Data:
TEXT
LoopContext
LoopContext
LoopContext
contains_key(key_string)
Returns True if the input object includes the specified key, matching key names case-sensitively. Returns False when the key is missing, or when the input is not an object.
Examples - contains_key
EXAMPLE 1
Input:
CODE
{{ {'A': 1, 'D': 3} | contains_key('D') }}
Return Data:
TEXT
True
EXAMPLE 2
Input:
CODE
{{ {'A': 1, 'D': 3} | contains_key('a') }}
Return Data:
TEXT
False
EXAMPLE 3
Input:
CODE
{{ 'a' | contains_key('a') }}
Return Data:
TEXT
False
EXAMPLE 4
Input:
CODE
{{ ['a', 'b', 'c'] | contains_key('a') }}
Return Data:
TEXT
False
contains_key_value_pair(search_object)
Returns True if the input object contains all key–value pairs from the search object. Returns False when any pair is missing or mismatched. Comparison is case-sensitive for both keys and values.
Returns True if the input object contains the specified value among its key-value pairs. Returns False when the value is not found or when the input is not an object. Comparison is case-sensitive for string values. The filter performs shallow comparison and does not search within nested structures.
CHECKING NESTED VALUES
To check for deeply nested values, serialize the entire object to JSON and use the in operator for substring matching.
Returns a Boolean that indicates whether the piped input and the comparison value are equivalent in content. Supports comparison of objects, arrays, strings, and numbers.
Returns a Boolean indicating whether the piped input and the comparison value represent equivalent data. The comparison is case-sensitive and ignores key order in JSON objects but respects element order in arrays.
Filters JSON objects or arrays by evaluating expressions that match specific field values or conditions. The filter can reference data within the same task (intra-task) or from another task in the playbook (inter-task).
The <TaskName> segment identifies the specific task within the current playbook whose output or metadata is being referenced.
The <DataField> segment identifies where the relevant information resides. It is typically a top-level key (e.g., returnData or contextData), but can also include nested attributes separated by dots (e.g., taskExecution.startDate or taskExecution.duration.Minutes).
The <SubscriptExpression> segment specifies how to traverse or extract elements from an array or object within a task's data node. It is always enclosed in square brackets and may include:
Indexes: Retrieves a single element by its zero-based index in the array.
Returns a Boolean value indicating whether the piped input object lacks the specified top-level value. The comparison is case-sensitive, shallow (values inside nested objects are ignored, unless they are stored as literal strings) and supports only positive integers and string values.
USAGE ADVISORY
Convert non-string input values, except positive integers, to text using either | tojson or | string before comparison.
{% set data = [
{'x': 'a'},
{'y': 'b'}
] %}
{{ { 'a': data | tojson }
| not_contain_value('[{"x": "a"}, {"y": "b"}]') }}
Return Data:
TEXT
False
EXAMPLE 6
Input:
CODE
{% set data = [
{'x': 'a'},
{'y': 'b'}
] %}
{{ { 'a': data | string }
| not_contain_value("[{'x': 'a'}, {'y': 'b'}]") }}
Return Data:
TEXT
False
EXAMPLE 6
Input:
CODE
{% set data = {'x': 'a', 'y': 'b'} %}
{{ { 'a': data | string }
| not_contain_value('{"x": "a", "y": "b"}') }}
Explanation: Inner quotes affect equality. The conversion data | string produces the Python-style string"{'x': 'a', 'y': 'b'}", which differs from the filter argument (JSON-style string).
Return Data:
TEXT
True
EXAMPLE 7
Input:
CODE
{% set data = {'x': 'a', 'y': 'b'} %}
{{ { 'a': data | tojson }
| not_contain_value("{'x': 'a', 'y': 'b'}") }}
Explanation: Inner quotes affect equality. The conversion data | tojsonproduces the JSON-style string '{"x": "a", "y": "b"}', which differs from the filter argument (Python-style string).
Return Data:
TEXT
True
not_equal(comparison_value)
Determines whether the piped input value differs from the specified comparison value. Returns True if the two values are different. Returns False if they are identical.
Examples - not_equal
EXAMPLE 1
Input:
CODE
{% set obj1= {"id": 1} %}
{% set obj2 = {"id": 2} %}
{{ obj1 | not_equal(obj2) }}
Return Data:
TEXT
True
EXAMPLE 2
Input:
CODE
{{ [1,2,3] | not_equal([1,2,3]) }}
Return Data:
TEXT
False
EXAMPLE 3
Input:
CODE
{{ "a" | not_equal("b") }}
Return Data:
TEXT
True
plus(added_value)
Returns the sum for numeric inputs or a combined sequence for strings, arrays, or objects. For objects with shared keys, values from the added value override those in the piped input.
Returns a JSON object where attribute values matching the specified regular expression pattern are replaced with the new value. The filter applies the regex to each value within the object.
Optional flags include:
Flags
Function
I
Enables case-insensitive matching.
S
Allows the dot (.) to match newline characters.
X
Enables extended mode, allowing spaces and comments in the pattern for readability.
Returns an object where values matching the specified JSON path are replaced with the new value. If the path does not match any element, the original JSON object is returned unchanged.
Serialization converts a complex data structure (e.g., dictionary/object or array) into a single text string, usually in JSON format, for easier storage, transfer, or comparison.
For example, when
CODE
{{ {'a': {'b': {'c': 3}}} | tojson }}
is run, the hierarchical dictionary structure is converted into a JSON-formatted text string:
CODE
{"a": {"b": {"c": 3}}}
Although conversion result looks similar to the original dictionary, the result is no longer a structured object. It is a single continuous text string. This means filters that operate on objects (like contains_value) will no longer work, but text-based operations (like the in operator) can be used.
Other text-based operations that can be applied to serialized objects include:
Replace — Modifies text within the serialized JSON.