DeleteItemsArrayByPathJSON
Deletes an element within an array based on a JSON path.
DeleteItemsArrayByPathJSON(
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 deletes 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=DeleteItemsArrayByPathJSON(
array=MyArray,
filterPath="[1].first_name"
)
)}}
{{SendMessage(message=PathArray)}}
[{"first_name":"Brad","last_name":"Pitt"},{"first_name":"Matt","last_name":"Damon"}]
[{"first_name":"Brad","last_name":"Pitt"}]
Updated 4 months ago