fork(7) download
  1. def jsonString = """{ "Errors": [],
  2. "Loans": [
  3. {
  4. "Applications": [
  5. {
  6. "id": 1,
  7. "name": "test"
  8. }
  9. ]
  10. },
  11. {
  12. "Applications": [
  13. {
  14. "id": 2,
  15. "name": "test3"
  16. },
  17. {
  18. "id": 3,
  19. "name": "test3"
  20. }
  21. ]
  22. }
  23. ]
  24. }"""
  25.  
  26. def json = new groovy.json.JsonSlurper().parseText(jsonString)
  27.  
  28. //To get all loan applications
  29. json.Loans.each {println it}
  30.  
  31. //The way you want
  32. def getLoanAt = { json.Loans[it] }
  33. println getLoanAt(0)
Success #stdin #stdout 0.96s 2252800KB
stdin
Standard input is empty
stdout
[Applications:[[id:1, name:test]]]
[Applications:[[id:2, name:test3], [id:3, name:test3]]]
[Applications:[[id:1, name:test]]]