GetItemsArrayByPathJSON
Returns an element within an array based on a JSON path.
GetItemsArrayByPathJSON(
array: str,
filterPath: str
)
Where:
- array: An array in the format '[{"first_name": "Brad", "last_name": "Pitt"}]' for example.
- filterPath: A string in JSONPath format to traverse the path to an element in a JSON structure.
Example
The example below returns an element in an array by specifying its JSONPath.
{{set(
name="MyArray",
value=AppendItemsArrayJSON(
array="[]",
items=[
'{
"first_name": "Brad",
"last_name": "Pitt"
}',
'{
"first_name": "Matt",
"last_name": "Damon"
}'
]
)
)}}
{{SendMessage(message=MyArray)}}
{{set(
name="PathArray",
value=GetItemsArrayByPathJSON(
array=MyArray,
filterPath="[1].first_name"
)
)}}
{{SendMessage(message=PathArray)}}
[{"first_name":"Brad","last_name":"Pitt"},{"first_name":"Matt","last_name":"Damon"}]
[{"first_name":"Matt","last_name":"Damon"}]
Updated 8 months ago