Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
5 Comments
Akash
Participant
0 Kudos

Please suggest

NTeunckens
Active Contributor
0 Kudos

Do you really need to use Groovy syntax for that?
An alternative could be the use of a Regular Expression ...

Akash
Participant
0 Kudos
  • If it is possible without groovy then no need to implement script.

Hi Akash,

Use below code to remove "__metadata" syntax: 

 

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

def Message processData(Message message)
{
    def body = message.getBody(java.lang.String) as String;
    def jsonParser = new JsonSlurper();
    def data = jsonParser.parseText(body);  
    data.d.results.each{ results ->
    results.remove('__metadata')
    }
    def JsonOutput = new JsonBuilder(data).toPrettyString()
    message.setBody(JsonOutput );
    return message;
}
 
Regards,
Carol Pereira
Akash
Participant
0 Kudos

thanks @carolpereira0378_2 . it is working.

Labels in this area