public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, ZetacoinException {
        try {
            String r = new String(loadStream(in, close), QUERY_CHARSET);
            logger.log(Level.FINE, "Zetacoin JSON-RPC response:\n{0}", r);
            try {
                Map response = (Map) JSON.parse(r);

                if (!expectedID.equals(response.get("id")))
                    throw new ZetacoinRPCException("Wrong response ID (expected: "+String.valueOf(expectedID) + ", response: "+response.get("id")+")");

                if (response.get("error") != null)
                    throw new ZetacoinException(JSON.stringify(response.get("error")));

                return response.get("result");
            } catch (ClassCastException ex) {
                throw new ZetacoinRPCException("Invalid server response format (data: \"" + r + "\")");
            }
        } finally {
            if (close)
                in.close();
        }
    }