'Jayway Jsonpath value as signed integer conditionally

I have a json string. I have to extract a field signed based on another field value. Example shown below:

{
  "stock" : {
    "BuyOrSell" : "SELL",
    "Units" : "2"
  }
}

I have to evaluate stock units as signed(+/-) based on ButOrSell value using jayway json path evaluator.

Like : if (BuyOrSell == 'SELL') concat("-", Units)

Any conditional expression supported in jayway.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source