There is a class

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; } } } 

I want to convert json to class

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

As I understand the error in the deserialization parameter. I tried

 List<RootObject> List<Result> 

I do not understand what type of data to register enter image description here

enter image description here

  • one
    I already threw my answer to you , pay attention not to the last line there var myObject = JsonConvert.DeserializeObject<RootObject>(json); - tym32167
  • jsonSerializer.Deserialize<RootObject>(json); - Dmitry Polyanin
  • @ tym32167 gives an error. See on the screen - Radzhab
  • I have this construction that works great with your Json JsonConvert.DeserializeObject<RootObject>(str) - tym32167
  • @DmitryPolyanin gives an error - Radzhab

1 answer 1

VisualStudio has a built-in tool - enter image description here

If you use it, the scheme is converted like this:

 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; } } 

Will the built-in tool help you?