fork download
  1. def json = """{
  2. "regions": [{
  3. "regionId": 10,
  4. "hotels": [{
  5. "roomInformation": [{
  6. "hotelRoomId": 1,
  7. "availableRooms": 1,
  8. "roomPrice": 100,
  9. "occupancySequenceOrder": 1,
  10. "providerRoomId": 1,
  11. "isExtranet": true
  12. }],
  13. "regionId": 1,
  14. "hotelId": 1,
  15. "boardTypeId": 1,
  16. "startDate": "2017-10-23T00:00:00",
  17. "endDate": "2017-10-30T00:00:00",
  18. "totalPrice": 1000,
  19. "providerInformation": {
  20. "hotelSpecialOfferDetails": [],
  21. "ratePlanCode": "xxx",
  22. "allAvailableResults": []
  23. },
  24. "providerHotelId": 25
  25. },
  26.  
  27. {
  28. "roomInformation": [{
  29. "hotelRoomId": 1,
  30. "availableRooms": 1,
  31. "roomPrice": 100,
  32. "occupancySequenceOrder": 1,
  33. "providerRoomId": 1,
  34. "isExtranet": true
  35. }],
  36. "regionId": 1,
  37. "hotelId": 1,
  38. "boardTypeId": 1,
  39. "startDate": "2017-10-23T00:00:00",
  40. "endDate": "2017-10-30T00:00:00",
  41. "totalPrice": 1000,
  42. "providerInformation": {
  43. "hotelSpecialOfferDetails": [],
  44. "ratePlanCode": "ggg",
  45. "allAvailableResults": []
  46. },
  47. "providerHotelId": 31
  48. }
  49. ],
  50. "errors": null
  51. }],
  52. "errors": null
  53. }"""
  54.  
  55. def jsonRes = new groovy.json.JsonSlurper().parseText(json)
  56. def providerhotelid = jsonRes.regions.hotels.providerHotelId.flatten()[0]
  57. def rateplancode = jsonRes.regions.hotels.providerInformation.ratePlanCode.flatten()[0]
  58.  
  59. println providerhotelid
  60. println rateplancode
Success #stdin #stdout 0.88s 4456448KB
stdin
Standard input is empty
stdout
25
xxx