I need a way to remove leading square brackets from a json file. Im doing it in SAP cloud platform integration (CPI). Currently I was thinking of using groovy but can't seem to find a way to do it. Heres the JSON example:
[{
"salesOrderNumber": "1234567",
"orderStatus": "Complete",
"customerPONumber": "7654321",
"soldToID": "ABC",
"soldToName": "CBA"
}
]
Thank you in advance
The Code I used for getting just one element, But I need to get multiple in case there are any.
def Message processData(Message message) {
def body = message.getBody(String.class);
def jsonParser = new JsonSlurper();
def jsonObject = jsonParser.parseText(body);
def json = JsonOutput.toJson(jsonObject[0]);
println(json);
message.setBody(json);
return message;
}