0

Есть класс

namespace xmltv
{
    public class Event
    {
        public string id { get; set; }
        public string eid { get; set; }
        public string start { get; set; }
        public string finish { get; set; }
        public string title { get; set; }
        public string description { get; set; }
        public string img { get; set; }
        public string age { get; set; }
    }

    public class Result
    {
        public string name { get; set; }
        public string id { get; set; }
        public string logo { get; set; }
        public string description { get; set; }
        public List<Event> events { get; set; }
    }

    public class RootObject
    {
        public List<Result> result { get; set; }
    }
}

Я хочу входящий json преобразовать в класс

var json = System.IO.File.ReadAllText("axi.json");
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue, RecursionLimit = 100 };
var rez = jsonSerializer.Deserialize<List<RootObject>>(json);

Как я понимаю ошибка в параметре десериализации. Я пробовал

List<RootObject>
List<Result>

Никак не пойму какой тип данных прописать введите сюда описание изображения

введите сюда описание изображения

Radzhab
  • 3,772

1 Answers1

2

В VisualStudio есть встроенный инструмент - введите сюда описание изображения

Если им воспользоваться, схема преобразуется вот так:

public class Rootobject
{
    public Result result { get; set; }
}

public class Result
{
    public string name { get; set; }
    public string id { get; set; }
    public string logo { get; set; }
    public string description { get; set; }
    public Event[] events { get; set; }
}

public class Event
{
    public string id { get; set; }
    public string eid { get; set; }
    public int start { get; set; }
    public int finish { get; set; }
    public string title { get; set; }
    public string img { get; set; }
    public string age { get; set; }
}

Не поможет ли Вам встроенный инструмент?