cancel
Showing results for 
Search instead for 
Did you mean: 

Jsonpath begins with

npise
New Contributor II

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"
},
]
1 ACCEPTED SOLUTION

npise
New Contributor II

Thank you all!!

jsonPath($, “entity.entries[*]”).filter(x => x.hasPath(‘type’) && x.type == ‘file’ && x.hasPath(‘name’) && x.name.startsWith(‘Send Email’)).length >0

This worked!

View solution in original post

3 REPLIES 3

bojanvelevski
Valued Contributor

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

Supratim
Contributor III

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

npise
New Contributor II

Thank you all!!

jsonPath($, “entity.entries[*]”).filter(x => x.hasPath(‘type’) && x.type == ‘file’ && x.hasPath(‘name’) && x.name.startsWith(‘Send Email’)).length >0

This worked!