用于谷歌嵌套响应的JSON到POJO

时间:2016-03-23 15:27:12

标签: json jackson pojo nest-api

我想将json响应从google nest thermostat转换为POJO以供进一步使用。

恒温器阵列包含一个设备ID 的数组,用于保存实际的设备值。我不知道如何为这个恒温器列表创建POJO模型,是否有人可以指导我朝正确的方向发展?

这是Json的反应,我得到了表格巢。

{
  "thermostats": {
    "A5K29Sp2Nr1IghCYK3Jj7MF0a0pXuhxk": {
      "humidity": 65,
      "locale": "en-US",
      "temperature_scale": "C",
      "is_using_emergency_heat": false,
      "has_fan": true,
      "software_version": "4.1",
      "has_leaf": true,
      "where_id": "gPn37UwCFT5l1y8iHzATIcLKJhFieKtX0Y1GeGA_DZ5X6N7db7FRgw",
      "device_id": "A5K29Sp2Nr1IghCYK3Jj7MF0a0pXuhxk",
      "name": "Basement (FB9B)",
      "can_heat": true,
      "can_cool": false,
      "hvac_mode": "heat",
      "target_temperature_c": 21.5,
      "target_temperature_f": 71,
      "target_temperature_high_c": 26,
      "target_temperature_high_f": 79,
      "target_temperature_low_c": 19,
      "target_temperature_low_f": 66,
      "ambient_temperature_c": 24.5,
      "ambient_temperature_f": 76,
      "away_temperature_high_c": 24,
      "away_temperature_high_f": 76,
      "away_temperature_low_c": 12.5,
      "away_temperature_low_f": 55,
      "structure_id": "kg24pb09IIaJjREeEj6RmBAASwE9VgI92bfPJoIZC4yHGP2s9hqX1g",
      "fan_timer_active": false,
      "fan_timer_timeout": "1970-01-01T00:00:00.000Z",
      "name_long": "Basement Thermostat (FB9B)",
      "is_online": true,
      "hvac_state": "off"
    }
  }
}

1 个答案:

答案 0 :(得分:0)

json中恒温器的内容应该像Map<String,Object>

那样建模