suppender
9/8/2017 - 9:42 AM

Gson解析工具类

Gson解析工具类

public class GsonImpl extends Json { 
    private Gson gson = new Gson(); 
  
  
    @Override
    public String toJson(Object src) { 
        return gson.toJson(src); 
    } 
  
  
    @Override
    public <T> T toObject(String json, Class<T> claxx) { 
        return gson.fromJson(json, claxx); 
    } 
  
  
    @Override
    public <T> T toObject(byte[] bytes, Class<T> claxx) { 
        return gson.fromJson(new String(bytes), claxx); 
    } 
 
  
 }