У меня есть следующий json, и я пытаюсь десериализовать его для вставки в таблицу SQL, я пытался использовать JsonConvert и JObject без положительного результата
Json
{
"id": "123123",
"publisherId": "Empresa",
"notificationType": "Orden",
"headers": {
"providerId": "ABC123"
},
"content": {
"id": "987987",
"orderId": "4444444",
"apiName": "Services",
"method": "GetOrder",
"verb": "GET",
"urlMethod": "https://api.com"
},
"contentVersion": "1.0"
}
Модель
public class Headers
{
public string providerId { get; set; }
}
public class Content
{
public string id { get; set; }
public string orderId { get; set; }
public string apiName { get; set; }
public string method { get; set; }
public string verb { get; set; }
public string urlMethod { get; set; }
}
public class RootModel
{
public string id { get; set; }
public string publisherId { get; set; }
public string notificationType { get; set; }
public Headers headers { get; set; }
public Content content { get; set; }
public string contentVersion { get; set; }
}
Код
public static List<Models.RootModel> getJson()
{
using (StreamReader r = new StreamReader("c:\\LOG\\20180528\\201805281039.json"))
{
string json = r.ReadToEnd();
return JsonConvert.DeserializeObject<Models.RootModel>(json);
}
}
Вы сообщаете мне следующую ошибку
Ошибка CS0029 Нет самоанализа конвертируемого типа 'WebApplication1.Models.RootModel' en 'System.Collections.Generic.List'
Я действительно не знаю, прав ли яотслеживать, нужно ли десериализацию вставлять в БД, или есть другой способ?
Заранее спасибо за помощь