Jsonpath begins with

Below is my input, i am trying filter for id where type == file and name begins with “Send Email”

expression i used in mapper jsonPath($, “entity.entries[?(@.type == ‘file’ && @.name =~ /Send Email.*?/i)].id”) but i am getting error Please check expression syntax and data types.

"entries":[
{
"type":
"folder"
"id":
"138491898043",
"name":
"processed Template"
}
{
"type":
"file"
"id":
"817753844208",
"name":
"Send Email Template (1).xlsx"
}
{
"type":
"file"
"id":
"817352978835",
"name":
"Send Email Template.xlsx"
},
{
"type":
"file"
"id":
"81735297",
"name":
"Hello World.xlsx"
},
]

Hi @npise,

You can use the following expression:

$entries.filter(x=>x.type == ‘file’ && x.name.startsWith(‘Send Email’)).map(y=>y.id)

You’ll get an array of id’s that match the condition.

Regards,
Bojan

1 Like

Can also try below expression-
jsonPath($, "$entries[?(value[‘type’] == ‘file’ && value[‘name’].startsWith('Send