需要解析的JSON
massage==>"{'deviceType':'CustomCategory','iotId':'LHGR0pgEEhI4FWZaIwAS000000','requestId':'123','checkFailedData':{},'productKey':'a17rRRuNTCD','gmtCreate':1607241627505,'deviceName':'aliServer','items':{'LightSwitch':{'value':1,'time':1607241627510},'CurrentTemperature':{'value':49,'time':1607241627510}}}"
多层解析
JSONObject object = JSONObject.fromObject(content);
JSONObject items = JSONObject.fromObject(object.getString("items"));
JSONObject LightSwitchs = JSONObject.fromObject(items.getString("LightSwitch")
String value = LightSwitchs.getString("value");
Long time = LightSwitchs.getLong("time");
System.out.println(value+"-------------"+time);
单层解析
JSONObject object = JSONObject.fromObject(content);
String deviceType = object.getString("deviceType")
System.out.println(deviceType);