前台传递过来的数据:
[{"aceneId":"","deviceCode":"27","deviceFirm":"春泉","deviceId":"1","deviceKind":"温控器","deviceName":"温控器001",
"deviceStation":"d8-b0-4c-b4-bc-a9","id":"110","isOn":"0","pattern":"制冷","permission":"1,00,99,0","registerAddress"
:"0081","registerNumber":"4","speed":"高档","temperature":"20","type":"0"},
{"aceneId":"","deviceCode":"16","deviceFirm":"春泉","deviceId":"2","deviceKind":"温控器","deviceName":"温控器002",
"deviceStation":"d8-b0-4c-b4-bc-a9","id":"111","isOn":"0","pattern":"制冷","permission":"1,00,99,0",
"registerAddress":"0081","registerNumber":"4","speed":"高档","temperature":"20","type":"0"}]
JSONArray jsonArray = JSONArray.fromObject(deviceList); String jsonString = jsonArray.getString(0); Map deviceMap = new HashMap<>(); Gson gson = new Gson(); deviceMap = gson.fromJson(jsonString, deviceMap.getClass()); System.out.println(deviceMap.get("deviceCode").toString());