fork(11) download
  1. def jsonString = """{
  2. "Result": {
  3. "Locations": [
  4. {
  5. "Latitude": 38.657,
  6. "Longitude": -120.377997
  7. },
  8. {
  9. "Latitude": 38.6566,
  10. "Longitude": -120.3791
  11. },
  12. {
  13. "Latitude": 38.658399,
  14. "Longitude": -120.3804
  15. },
  16. {
  17. "Latitude": 38.655499,
  18. "Longitude": -120.38496
  19. },
  20. {
  21. "Latitude": 38.654,
  22. "Longitude": -120.3819
  23. },
  24. {
  25. "Latitude": 38.6537,
  26. "Longitude": -120.3897
  27. },
  28. {
  29. "Latitude": 38.6544,
  30. "Longitude": -120.382604
  31. },
  32. {
  33. "Latitude": 38.655602,
  34. "Longitude": -122.386402
  35. }
  36. ]
  37. }
  38. }"""
  39.  
  40. def json = new groovy.json.JsonSlurper().parseText(jsonString)
  41. def locations = json.Result.Locations
  42. def randomNumber = new Random().nextInt(locations.size())
  43. def latitude = locations[randomNumber].Latitude
  44. def longitude = locations[randomNumber].Longitude
  45. println latitude
  46. println longitude
  47.  
Success #stdin #stdout 0.98s 87384KB
stdin
Standard input is empty
stdout
38.654
-120.3819