on 12-17-2023 7:29 PM
Hi Team,
I have the below payload in Json format and i require to add the root node with data.
Current Json Payload
{
"attributes": {
"type": "TEST",
"url": "www"
},
"Id": "XYZ",
"IsDeleted": No,
}
Required Json Payload.
{ "data": {
"attributes": {
"type": "TEST",
"url": "www"
},
"Id": "XYZ",
"IsDeleted": No,
}
}
When i am using the below login in groovy script, its failing with error.
def actPayload = [data: body]; messageLog.addAttachmentAsString('03-REQUEST-json', JsonOutput.prettyPrint(actPayload), 'text/plain');
Can anyone help in groovy script on this issue.
Regards,
Ali
Hi Hyder Ali,
Please use the following code:
import groovy.json.*;
def Message jsonCreate (Message message)
{
def builder = new JsonBuilder();
builder{
data{
attributes{
type("test")
url("www")
}
id("1234")
isDeleted("No")
}
}
message.setBody(builder.toPrettyString())
return message;
}
Thanks,
Regards,
Raihan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.