package com.dy.testClient.rmiClient;
|
|
import com.alibaba.fastjson2.JSON;
|
|
public class RmiResponseVo {
|
|
public boolean success = true ;
|
|
public String errorInfo ;
|
|
public String code ;
|
|
public Object obj ;
|
|
/**
|
* 对象转成json
|
* @return json
|
* @throws Exception 异常
|
*/
|
public String toJson()throws Exception{
|
try{
|
return JSON.toJSONString(this) ;
|
//return new JSONSerializer().exclude(new String[]{"class", "*.class"}).deepSerialize(this);
|
}catch(Exception e){
|
throw new Exception(e.getMessage() , e ) ;
|
}
|
}
|
/**
|
* json转成对象
|
* @param json
|
* @return 对象
|
* @throws Exception 异常
|
*/
|
public static RmiResponseVo jsonToObject(String json, Class<?> clazz)throws Exception{
|
try{
|
return JSON.parseObject(json, RmiResponseVo.class) ;
|
//JSONDeserializer<RmiResponseVo> jsonD = new JSONDeserializer<RmiResponseVo>() ;
|
//jsonD.use("obj", clazz) ;
|
//RmiResponseVo resp = jsonD.deserialize(json, RmiResponseVo.class) ;
|
//return resp ;
|
}catch(Exception e){
|
throw new Exception(e.getMessage() , e ) ;
|
}
|
}
|
|
public boolean isSuccess() {
|
return success;
|
}
|
|
public void setSuccess(boolean success) {
|
this.success = success;
|
}
|
|
public String getErrorInfo() {
|
return errorInfo;
|
}
|
|
public void setErrorInfo(String errorInfo) {
|
this.errorInfo = errorInfo;
|
}
|
|
public String getCode() {
|
return code;
|
}
|
|
public void setCode(String code) {
|
this.code = code;
|
}
|
|
public Object getObj() {
|
return obj;
|
}
|
|
public void setObj(Object obj) {
|
this.obj = obj;
|
}
|
}
|