GetIndexesOfItemsArrayJSON
Returns the index of an item within an array based on a JSON path.
GetIndexesOfItemsArrayJSON(
  array: str, 
  filterPath: str
)
Where:
- array: An array in the format '[{"first_name": "Brad", "last_name": "Pitt"}][{"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 the index of 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="PathIndex",
    value=GetIndexesOfItemsArrayJSON(
        array=MyArray, 
        filterPath="[1].first_name"
        )
)}}
{{SendMessage(message=PathIndex)}}[\{"first_name":"Brad","last_name":"Pitt"},\{"first_name":"Matt","last_name":"Damon"}]
1Updated 7 months ago
