All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.tdchain.RPCResultJSONObject Maven / Gradle / Ivy

There is a newer version: 3.0.1.TD1
Show newest version
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