on 2023 Oct 13 10:12 AM
Hi,
I am looking to convert below JSON to XML and use it in mapping and send to SFDC. But I am unable to convert due to Attributes coming in the response from S4.
{
"@odata.context": "$metadata#QualityNotification",
"@odata.metadataEtag": "W/\"20231011103819\"",
"value": [
{
"@odata.etag": "W/\"SADL-020230802142305C~20230802142305\"",
"QualityNotification": "200000000",
}
]
}
Could you help me and guide how I can remove the attributes and pass only the required values?
Request clarification before answering.
Please upvote or accept the answer and close the thread.
Regards,
Sri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below should work.
Also purpose of sharing these references to reuse bit of it and modify as per your requirement.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.JsonSlurper;
import groovy.json.JsonOutput;
import groovy.json.*;
def Message processData(Message message)
{
println "You can print and see the result in the console!"
//Body
def body = message.getBody(String);
def jsonSlurper = new JsonSlurper();
def list = jsonSlurper.parseText(body);
list.remove('@odata.context');
list.remove('@odata.metadataEtag');
list.value.each{
it.remove('@odata.etag');
}
def jsonOP = JsonOutput.toJson(list)
message.setBody(jsonOP);
return message;
}
Regards,
Sri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vignesh,
Have you tried below?
https://answers.sap.com/questions/641173/how-to-remove-fields-in-json-after-conversion-in-g.html
Regards,
Sri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
29 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.