fork(1) download
  1. def json = """{ "body": {
  2. "devices": [{
  3. "_id": "xxxxxxxxxx",
  4. "cipher_id": "xxxxxxxx",
  5. "last_status_store": 1502808369,
  6. "modules": [{
  7. "_id": "xxxxxxx",
  8. "type": "xxxxxxx",
  9. "last_message": 1502808365,
  10. "last_seen": 1502808359,
  11. "dashboard_data": {
  12. "time_utc": 1502808359,
  13. "Temperature": 18.9,
  14. "temp_trend": "down",
  15. "Humidity": 27,
  16. "date_max_temp": 1502804720,
  17. "date_min_temp": 1502808359,
  18. "min_temp": 18.9,
  19. "max_temp": 22.2
  20. },
  21. "data_type": [
  22. "Temperature",
  23. "Humidity"
  24. ],
  25. "last_setup": 1502731328,
  26. "battery_vp": 6354,
  27. "battery_percent": 100,
  28. "rf_status": 67,
  29. "firmware": 44
  30. }],
  31. "place": {
  32. "altitude": 63.395306309052,
  33. "city": "xxxxxx",
  34. "country": "US",
  35. "timezone": "America/New_York",
  36. "location": [-72.532673,
  37. 42.0425917
  38. ]
  39. },
  40. "station_name": "xxxxxxxxxxx",
  41. "type": "NAMain",
  42. "dashboard_data": {
  43. "AbsolutePressure": 1004.6,
  44. "time_utc": 1502808354,
  45. "Noise": 50,
  46. "Temperature": 22.7,
  47. "temp_trend": "up",
  48. "Humidity": 69,
  49. "Pressure": 1012.1,
  50. "pressure_trend": "stable",
  51. "CO2": 0,
  52. "date_max_temp": 1502808290,
  53. "date_min_temp": 1502801263,
  54. "min_temp": 21.3,
  55. "max_temp": 22.7
  56. },
  57. "data_type": [
  58. "Temperature",
  59. "CO2",
  60. "Humidity",
  61. "Noise",
  62. "Pressure"
  63. ],
  64. "co2_calibrating": false,
  65. "date_setup": 1502731277,
  66. "last_setup": 1502731277,
  67. "module_name": "Indoor",
  68. "firmware": 132,
  69. "last_upgrade": 1502731279,
  70. "wifi_status": 51
  71. }]
  72. },
  73. "status": "ok",
  74. "time_exec": 0.019752025604248,
  75. "time_server": 1502808443
  76.  
  77. }"""
  78. def pJson = new groovy.json.JsonSlurper().parseText(json)
  79. println pJson.body.devices.modules.dashboard_data.Temperature.flatten()
  80. println pJson.body.devices.dashboard_data.Temperature.flatten()
Success #stdin #stdout 0.92s 4456448KB
stdin
Standard input is empty
stdout
[18.9]
[22.7]