Object test = ("test");
JSONObject jsonObject = (test);
BatteryParamInfo battery = (jsonObject, );
通过这三个步骤就可以将redis中取出的json字符串转成指定的对象了。
还可以封装泛型,如下:
public <T> T getObject(String key,Class<T> t){
Object str = (key == null ? null : ().get(key));
JSONObject jsonObject = (str);
T obj= (jsonObject, t);
return obj;
}