/// <summary> /// Parses a Response from a raw JSON string /// </summary> public static Response ParseFrom(long token, string buf) { //we check here because it's possibly very expensive to ship this buf around in the call stack if (Log.IsTraceEnabled) { Log.Trace($"JSON Recv: Token: {token}, JSON: {buf}"); } var jsonResp = ParseJson(buf); var responseType = jsonResp[TypeKey].ToObject <ResponseType>(); var responseNotes = jsonResp[NotesKey]?.ToObject <List <ResponseNote> >() ?? new List <ResponseNote>(); ErrorType?et = jsonResp[ErrorKey]?.ToObject <ErrorType>(); var profile = Profile.FromJsonArray((JArray)jsonResp[ProfileKey]); var backtrace = Backtrace.FromJsonArray((JArray)jsonResp[BacktraceKey]); var res = new Response(token, responseType) { ErrorType = et, Profile = profile, Backtrace = backtrace, Data = (JArray)jsonResp[DataKey] ?? new JArray(), Notes = responseNotes }; return(res); }
/// <summary> /// Parses a Response from a raw JSON string /// </summary> public static Response ParseFrom(long token, string buf) { Log.Trace($"JSON Recv: Token: {token}, JSON: {buf}"); var jsonResp = JObject.Parse(buf); var responseType = jsonResp[TypeKey].ToObject <ResponseType>(); var responseNotes = jsonResp[NotesKey]?.ToObject <List <ResponseNote> >() ?? new List <ResponseNote>(); ErrorType?et = jsonResp[ErrorKey]?.ToObject <ErrorType>(); var profile = Profile.FromJsonArray((JArray)jsonResp[ProfileKey]); var backtrace = Backtrace.FromJsonArray((JArray)jsonResp[BacktraceKey]); var res = new Response(token, responseType) { ErrorType = et, Profile = profile, Backtrace = backtrace, Data = (JArray)jsonResp[DataKey] ?? new JArray(), Notes = responseNotes }; return(res); }