cn.tdchain.RPCResultJSONObject Maven / Gradle / Ivy
package cn.tdchain;
import cn.tdchain.jbcc.rpc.RPCResult;
import com.alibaba.fastjson.JSONObject;
public class RPCResultJSONObject {
public static RPCResult parseObject(String source, Class tClass) {
if (source == null) {
return null;
}
try {
RPCResult result = JSONObject.parseObject(source, RPCResult.class);
Object entity = result.getEntity();
if (entity == null) {
return result;
}
T t = JSONObject.parseObject(entity.toString(), tClass);
result.setEntity(t);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static RPCResult parseObject(RPCResult source, Class tClass) {
if (source == null) {
return null;
}
try {
RPCResult result = source;
Object entity = result.getEntity();
if (entity == null) {
return result;
}
T t = JSONObject.parseObject(entity.toString(), tClass);
result.setEntity(t);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy