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

Optional output target path variable from a mapper

walkerline117
Contributor

Hi

In a mapper, how could i do so that, depending on the left side expression, i can choose if a target path variable should be output or not.

For example,
if $a is null, then nothing should be output in target pathโ€ฆ else, it should output the value of $a.

I found if i define this target path, it will always be output no matter what.

image

so in above screenshot, if $a has no value, then $test should not be output at all. How to do that then?

2 REPLIES 2

tstack
Former Employee

Unfortunately, thereโ€™s no direct way to do that at the moment. One option is to use a second mapper to delete the property if it is null using a path like $[?(key == 'a' && value == null)]. Itโ€™s a reasonable, if uncommon, request. Iโ€™ll file feature request and see if we can come up with a solution.

walkerline117
Contributor

Thanks, we need such things a lot. And in some other ESB tools in industry, they have something like optional paramters. But this is not a term in Snaplogic yet.

BTW. you mentioned about 2 mappers, could you please elaborate it a little bit? How I can construct the 2nd mapper?

Thanks