Search in sources :

Example 31 with JSONRPC2Response

use of com.thetransactioncompany.jsonrpc2.JSONRPC2Response in project starcoin-java by starcoinorg.

the class JsonRPCClient method getSubObject.

/**
 * 获取单个对象的属性值接口
 *
 * @param session
 * @param method    rpc接口的方法名
 * @param params    rpc接口的参数列表
 * @param requestId 请求id
 * @param clazz     返回对象的封装类
 * @return
 * @throws JSONRPC2SessionException
 */
protected T getSubObject(JSONRPC2Session session, String method, List<Object> params, int requestId, String subKey, Class<T> clazz) throws JSONRPC2SessionException {
    JSONRPC2Request request = new JSONRPC2Request(method, params, requestId);
    JSONRPC2Response response = session.send(request);
    if (response.indicatesSuccess()) {
        Object result = response.getResult();
        if (result != null) {
            JSONObject jb = JSON.parseObject(result.toString());
            return jb.getObject(subKey, clazz);
        }
    }
    return null;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONRPC2Response(com.thetransactioncompany.jsonrpc2.JSONRPC2Response) JSONObject(com.alibaba.fastjson.JSONObject) JSONRPC2Request(com.thetransactioncompany.jsonrpc2.JSONRPC2Request)

Aggregations

JSONRPC2Response (com.thetransactioncompany.jsonrpc2.JSONRPC2Response)31 JSONRPC2Error (com.thetransactioncompany.jsonrpc2.JSONRPC2Error)24 HashMap (java.util.HashMap)24 Map (java.util.Map)6 JSONObject (com.alibaba.fastjson.JSONObject)4 JSONRPC2Request (com.thetransactioncompany.jsonrpc2.JSONRPC2Request)4 InetAddress (java.net.InetAddress)3 UnknownHostException (java.net.UnknownHostException)3 ClientAppManager (net.i2p.app.ClientAppManager)3 AuthToken (net.i2p.i2pcontrol.security.AuthToken)3 Router (net.i2p.router.Router)3 RouterVersion (net.i2p.router.RouterVersion)3 ReseedChecker (net.i2p.router.networkdb.reseed.ReseedChecker)3 Rate (net.i2p.stat.Rate)3 RateStat (net.i2p.stat.RateStat)3 UpdateManager (net.i2p.update.UpdateManager)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1