cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Jsonpath - how to use parameters or variables inside a jsonpath

swright
New Contributor III

Using jsonpath as the expression in a mapper snap the following works:

jsonPath($, โ€œ$entity.items[?(@.AssignmentNumber==โ€˜E3163300-2โ€™)].links[*]โ€).find(x=>x.name == โ€˜assignedPayrollsโ€™).href

I want to pass in the assignment number from a parameter but this doesnโ€™t seem to work:

jsonPath($, โ€œ$entity.items[?(@.AssignmentNumber=='_AssignmentNumber)].links[*]โ€).find(x=>x.name == โ€˜assignedPayrollsโ€™).href

This is with parameter _AssignmentNumber set to the value that works which is โ€˜E3163300-2โ€™

How can I get jsonpath to work with parameters or variables?

1 ACCEPTED SOLUTION

j_angelevski
Contributor III

Hi @swright,

You need to concatenate the jsonPath with the pipeline parameter.

jsonPath($, "$entity.items[?(value.AssignmentNumber=='" + _AssignmentNumber + "')].links[*]").find(x=>x.name == "assignedPayrolls").href

View solution in original post

2 REPLIES 2

j_angelevski
Contributor III

Hi @swright,

You need to concatenate the jsonPath with the pipeline parameter.

jsonPath($, "$entity.items[?(value.AssignmentNumber=='" + _AssignmentNumber + "')].links[*]").find(x=>x.name == "assignedPayrolls").href

swright
New Contributor III

Thank you! Your solution worked perfectly! I had tried something like that before and it failed. It was probably my syntax but your syntax worked on the first try!