Tuesday, 8 August 2023

Remove some extra nodes from json format using groovy script


import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.json.JsonSlurper
import groovy.json.JsonOutput


def Message processData(Message message) {

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

def jsonParser = new JsonSlurper()

def jsonObject = jsonParser.parseText(body)

message.setBody(JsonOutput.toJson(jsonObject["rows"]))

return message;

}


No comments:

Post a Comment