Guest User

Untitled

a guest
Oct 20th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import net.sf.json.JSONObject
  2. import groovy.json.JsonSlurper
  3. import static com.axeda.drm.sdk.scripto.Request.*;
  4.  
  5. try {
  6. // just get the string body content
  7. response = [body: body]
  8. response.element = []
  9.  
  10. // parse the text into a JSON Object or JSONArray suitable for traversing in Groovy
  11. // this assumes the body is stringified JSON
  12. def slurper = new JsonSlurper()
  13. def result = slurper.parseText(body)
  14.  
  15. result.each{ response.element << it }
  16.  
  17. } catch (Exception e) {
  18. response = [
  19. faultcode: 'Groovy Exception',
  20. faultstring: e.message
  21. ];
  22. }
  23.  
  24. return ["Content-Type": "application/json","Content":JSONObject.fromObject(response).toString(2)]
Add Comment
Please, Sign In to add comment