Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import net.sf.json.JSONObject
- import groovy.json.JsonSlurper
- import static com.axeda.drm.sdk.scripto.Request.*;
- try {
- // just get the string body content
- response = [body: body]
- response.element = []
- // parse the text into a JSON Object or JSONArray suitable for traversing in Groovy
- // this assumes the body is stringified JSON
- def slurper = new JsonSlurper()
- def result = slurper.parseText(body)
- result.each{ response.element << it }
- } catch (Exception e) {
- response = [
- faultcode: 'Groovy Exception',
- faultstring: e.message
- ];
- }
- return ["Content-Type": "application/json","Content":JSONObject.fromObject(response).toString(2)]
Add Comment
Please, Sign In to add comment