I would like to apply a filter on the input payload. The input is XML like:
<result>
<person>
<id>1</id>
<zipcode>1111AB </zipcode>
<housenr>1 </housenr>
</person>
<person>
<id>1</id>
<zipcode>1111AC </zipcode>
<housenr>2</housenr>
</person>
<person>
<id>1</id>
<zipcode>1111AD </zipcode>
<housenr>3</housenr>
</person>
<person>
<id>1</id>
<zipcode>1111AB </zipcode>
<housenr>4</housenr>
</person>
</result>
The end user is able to search on zipcode and optionally a housenr. The output json is like:
{
persons: [{
id: "1"
address: "1111AB 1"
},
{
id: "2",
address: "1111AC 1"
}
]
}
So I had the idea to filter a map like so:
{
persons: payload.result.*person filter ($.zipcode == flowVars.zipcode) map{
id: $.id,
address: $.zipcode ++ $.housenr
}
I would like to know if it would be possible make that filter conditional. For example if flowVars Zipcode and Housnr are null then the filter should not be applied. Or if Zipcode is filled but housnr not, then only zipcode filter should be applied.
Help welcome!
thanks