public static JSONRPCResult fromJSON(JSONObject result) throws RPCException { ResultType type = ResultType.fromID(result.getString("type").charAt(0)); switch (type) { // TODO case ACK: return new AckResponse(); case AT: return TableResult.fromJSON(result); case INDEX: return IndexResult.fromJSON(result); case NAK: return new NakResult(); case PONG: return new PongResult(); case VALUE: return ValueResult.fromJSON(result); default: throw new RPCException(JSONRPCError.MISSING_RESULT_TYPE); } }