public void Read(string response, IServerResponseReaderObserver observer) { using (var jsonReader = new JsonReader(response)) { IDictionary <string, object> jsonObject; try { jsonObject = jsonReader.ReadValue() as IDictionary <string, object>; } catch (FormatException fe) { observer.OnInvalidJsonResponse(fe); return; } if (jsonObject.ContainsKey(ApiOperation.ApiError)) { var errorObj = jsonObject[ApiOperation.ApiError] as IDictionary <string, object>; var code = errorObj[ApiOperation.ApiErrorCode] as string; var message = errorObj[ApiOperation.ApiErrorMessage] as string; observer.OnErrorResponse(code, message); return; } observer.OnSuccessResponse(jsonObject, response); } }
public void Read(string response, IServerResponseReaderObserver observer) { using (var jsonReader = new JsonReader(response)) { IDictionary<string, object> jsonObject; try { jsonObject = jsonReader.ReadValue() as IDictionary<string, object>; } catch (FormatException fe) { observer.OnInvalidJsonResponse(fe); return; } if (jsonObject.ContainsKey(ApiOperation.ApiError)) { var errorObj = jsonObject[ApiOperation.ApiError] as IDictionary<string, object>; var code = errorObj[ApiOperation.ApiErrorCode] as string; var message = errorObj[ApiOperation.ApiErrorMessage] as string; observer.OnErrorResponse(code, message); return; } observer.OnSuccessResponse(jsonObject, response); } }