я получаю следующий ответ при вызове API (ожидается, что это, это часть функционального теста для обработки плохого запроса):Вопросов десериализации JSON ответа
HTTP/1.1 400 Bad Request Date: Fri, 24 Jan 2014 17:43:39 GMT Sforce-Limit-Info: api-usage=5/5000 Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked
16F [{"message":"\nSELECT id, name, description FROM BadObject\n
^\nERROR at Row:1:Column:35\nsObject type 'BadObject' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_TYPE"}] 0
Я пытаюсь десериализациями его в следующий класс:
public class ErrorResponse
{
public string message;
public string errorCode;
}
Используя следующий код:
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(response);
Однако, когда я пытаюсь десериализации его, Я получаю следующее сообщение об ошибке:
{"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Salesforce.Common.Models.ErrorResponse' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath '', line 1, position 1."}
Я подозреваю, что это \ n (новая строка) вызывает проблемы. Я попытался заменить "\ n" на "\ n", но он не сработал.
Мысли?