Exemplo n.º 1
0
 private <T> Object getBean(JSONObject jsonObject, Class<T> clazz) {
   // 声明JsonConfig对象
   JsonConfig cfg = new JsonConfig();
   // 设置属性包装器
   cfg.setPropertySetStrategy(new PropertyStrategyWrapper(PropertySetStrategy.DEFAULT));
   // 设置要转换成的JavaBean
   cfg.setRootClass(clazz);
   // 转换
   Object object = JSONObject.toBean(jsonObject, cfg);
   return object;
 }