Wednesday, 16 September 2020

One line script to remove all double quotes for integer in Json data

 It is simple to remove the double quotes from the json data for the individual values. Earlier we used to pull the value in xpath and convert that value to interger to remove the double quotes.

But it makes more easier.

Groovy Script:

import com.sap.gateway.ip.core.customdev.util.Message;

def Message processData(Message message) {

def body = message.getBody(java.lang.String) as String;

// remove double quotes from all integer vaules in json data

String output = body.replaceAll("\"(\\d+)\"", "\$1");

message.setBody(output);

return message;

}



No comments:

Post a Comment