JsonSerializationException
От: Funny Rabbit Россия  
Дата: 10.01.24 10:03
Оценка:
Имеется такой код (достался по наследству).

List<LogRestIntegrationEntity> logRestIntegrations = null;
try
{
    logRestIntegrations = JsonConvert.DeserializeObject<List<LogRestIntegrationEntity>>(MESRestRequestService.GetFromMesRest($"{Properties.Settings.Default.MesRest}/logs/rest-integrations-log/{reportName}/{systemName}"));
}
catch (Newtonsoft.Json.JsonSerializationException e)
{
    Debug.Write(e.ToString());
    throw e;  
}


В дебаге вот такую ошибку выдает. Причем в релизе ошибка не появляется. Все отрабатывает.

Исключение типа "Newtonsoft.Json.JsonSerializationException" возникло в GWM.MES.App.exe, но не было обработано в коде пользователя
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[GWM.MES.App.REST.Entitys.LogEntities.LogRestIntegrationEntity]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'timestamp', line 1, position 13.


Как победить?
То что меня не убивает, делает меня умнее.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.