Functions from V - Z

where

Filter on each element and return the new collection of filtered elements which match a specific condition.

where([<collection/instance>], , )

ParameterRequiredTypeDescription
<collection/instance>YesarrayThe collection with the items
<iteratorName>Yesiterator nameThe key item
<function>YesexpressionCondition function used to filter items
Return ValueTypeDescription
<new-collection/new-object>array/objectThe new collection where each element has been filtered with the function

Example 1

This example generates a new collection:

where(createArray(0, 1, 2, 3), x, x > 1)

And returns the result [2, 3].

Example 2

These examples generate a new collection:

where(json("{'name': 'jack', 'age': '15'}"), x, x.value == 'jack')
where(json("{'name': 'jack', 'age': '15'}"), x=> x.value == 'jack')

And return the result ['name:jack', 'age:15']. Note that the second expression is a lambda expression, which some find more readable.

xml

Return the XML version of a string that contains a JSON object.

xml('')


ParameterRequiredTypeDescription
<value>YesstringThe string with the JSON object to convert. The JSON object must have only one root property, which can't be an array. Use \ as an escape character for the double quotation mark (").
Return valueTypeDescription
<xml-version>objectThe encoded XML for the specified string or JSON object

Example 1

This example creates the XML version for a string, which contains a JSON object:

xml(json('{ \"name\": \"Sophia Owen\" }'))

And returns the result XML:

Sophia Owen

Example 2

Suppose you have a person JSON object, seen below:

{  
  "person": {  
    "name": "Sophia Owen",  
    "city": "Seattle"  
  }  
}

This example creates XML of a string that contains this JSON object:

xml(json('{\"person\": {\"name\": \"Sophia Owen\", \"city\": \"Seattle\"}}'))

And returns the result XML:

<person>
  <name>Sophia Owen</name>
  <city>Seattle</city>
<person

xPath

Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values. An XPath expression (referred to as XPath) helps you navigate an XML document structure so that you can select nodes or compute values in the XML content.

xPath('', '')


ParameterRequiredTypeDescription
<xml>YesanyThe XML string to search for nodes or values that match an XPath expression value
<xPath>YesanyThe XPath expression used to find matching XML nodes or values
Return ValueTypeDescription
<xml-node>XMLAn XML node when only a single node matches the specified XPath expression
<value>anyThe value from an XML node when only a single value matches the specified XPath expression
<[<xml-node1>, <xml-node2>, ...]>arrayAn array with XML nodes or values that match the specified XPath expression

Example 1

This example finds nodes that match the <name></name> node in the specified arguments, and returns an array with those node values:

xPath(items, '/produce/item/name')

The arguments include the items string, which contains this XML:

"<?xml version="1.0"?> <produce> <item> <name>Gala</name> <type>apple</type> <count>20</count> </item> <item> <name>Honeycrisp</name> <type>apple</type> <count>10</count> </item> </produce>"

Here's the resulting array with the nodes that match <name></name>:

[ Gala, Honeycrisp ]

Example 2

Following example 1, this example finds nodes that match the <count></count> node and adds those node values with the sum() function:

xPath(xml(parameters('items')), 'sum(/produce/item/count)')

And returns the result 30.

year

Return the year of the specified timestamp.

year('')

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
Return valueTypeDescription
<year>integerThe year in the specified timestamp

Example

This example evaluates the timestamp for the year:

year('2018-03-15T00:00:00.000Z')

And it returns the result 2018.