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!