private Response ReadJsonResponse(JsonReader json, long token, ILogger logger) { Spec.Response retval = new Spec.Response(); retval.token = token; if (!json.Read() || json.CurrentToken != JsonToken.ObjectStart) { throw new RethinkDbInternalErrorException("Expected a readable JSON object in response"); } while (true) { if (!json.Read()) { throw new RethinkDbInternalErrorException("Unexpected end-of-frame reading JSON response"); } if (json.CurrentToken == JsonToken.ObjectEnd) { break; } if (json.CurrentToken != JsonToken.MemberName) { throw new RethinkDbInternalErrorException(String.Format("Unexpected JSON state; expected MemberName, but was {0}", json.CurrentToken)); } string property = (string)json.CurrentTokenValue; if (property == "t") { retval.type = ReadResponseType(json); } else if (property == "r") { retval.response.AddRange(ReadDatumArray(json)); } else if (property == "b") { retval.backtrace = ReadBacktrace(json); } else if (property == "p") { logger.Warning("Profiling is not currently supported by rethinkdb-net; profiling data will be discarded"); DiscardNextJsonValue(json); // read the value so that the reader isn't sitting at the unexpected property's vaue } else { logger.Information("Unexpected property {0} in JSON response; ignoring", property); DiscardNextJsonValue(json); // read the value so that the reader isn't sitting at the unexpected property's vaue } } return(retval); }
private Response ReadJsonResponse(JsonReader json, long token, ILogger logger) { Spec.Response retval = new Spec.Response(); retval.token = token; if (!json.Read() || json.CurrentToken != JsonToken.ObjectStart) throw new RethinkDbInternalErrorException("Expected a readable JSON object in response"); while (true) { if (!json.Read()) throw new RethinkDbInternalErrorException("Unexpected end-of-frame reading JSON response"); if (json.CurrentToken == JsonToken.ObjectEnd) break; if (json.CurrentToken != JsonToken.MemberName) throw new RethinkDbInternalErrorException("Unexpected JSON state"); string property = (string)json.CurrentTokenValue; if (property == "t") retval.type = ReadResponseType(json); else if (property == "r") retval.response.AddRange(ReadDatumArray(json)); else if (property == "b") retval.backtrace = ReadBacktrace(json); else if (property == "p") logger.Warning("Profiling is not currently supported by rethinkdb-net; profiling data will be discarded"); else logger.Information("Unexpected property {0} in JSON response; ignoring", property); } return retval; }