Forum Discussion

bgoh29's avatar
bgoh29
Occasional Contributor
3 years ago

how do I change the input value within JSON in the request body

I want to modify the values within JSON in the request body. Here's an example of the request body

 

{  "driverId":  "${userInfo#Respoinse#$id}, 

"otherDetails" : "${driverDetails#Response#$details}"

 

I want to reverse the string value of parameter otherDetails. 

I have tried a few combinations  and none of them works

 

  • ${driverDetails#Response#$details.reverse()} 
  • ${driverDetails#Response#$details}.toString().reverse()
  • $({driverDetails#Response#$details}).reverse()
  • ${${driverDetails#Response#details}.reverse()} 

 

Appreciate some help here. 

How do I reverse the string value within the ${ } or there are other ways to do that? 

 

  • We need to use ${=} to execute the Groovy code. And inside the code we can use the SoapUI property.

     

    An example:

    ${="${#TestCase#petName}".reverse()}

     Please note that the quotes make a string object, otherwise it would be treated as an identifier.

     

    Best regards,

    Karel

     

  • KarelHusa's avatar
    KarelHusa
    Champion Level 1

    We need to use ${=} to execute the Groovy code. And inside the code we can use the SoapUI property.

     

    An example:

    ${="${#TestCase#petName}".reverse()}

     Please note that the quotes make a string object, otherwise it would be treated as an identifier.

     

    Best regards,

    Karel