c#json格式太复杂了

时间:2015-08-08 07:18:26

标签: c# json

[
    {
        "Location": "St Kilda",
        "Name": "Movie Plaza theatre",
        "Day": "Monday",
        "Session": [
                    { "Moive": "Ant-man", "Time": "11 am", "Seat": 20 },
                    { "Moive": "Bat-man", "Time": "12 pm", "Seat": 20 },
                    { "Moive": "Spider-man", "Time": "1 pm", "Seat": 20 },
                    { "Moive": "Super-man", "Time": "2 pm", "Seat": 20 },
                    { "Moive": "DeadPool", "Time": "3 pm", "Seat": 20 }
                  ]
    },
     {
        "Location": "St Kilda",
        "Name": "Movie Plaza theatre",
        "Day": "Tuesday",
        "Session": [
                    { "Moive": "Ant-man", "Time": "11 am", "Seat": 20 },
                    { "Moive": "Bat-man", "Time": "12 pm", "Seat": 20 },
                    { "Moive": "Spider-man", "Time": "1 pm", "Seat": 20 },
                    { "Moive": "Super-man", "Time": "2 pm", "Seat": 20 },
                    { "Moive": "DeadPool", "Time": "3 pm", "Seat": 20 }
                  ]
   }
]

有没有办法让这些数据变得简单,所以我不需要创建7次才能在不同的日期显示这些数据。以及如何在C#中显示所有这些数据。

1 个答案:

答案 0 :(得分:0)

试试这样:

methodC

然后您可以迭代 public class Session { public string Moive { get; set; } public string Time { get; set; } public int Seat { get; set; } } public class RootObject { public string Location { get; set; } public string Name { get; set; } public string Day { get; set; } public List<Session> Session { get; set; } } var obj = JsonConvert.DeserializeObject<List<RootObject>>(json); 以操纵您的数据。

enter image description here

然后你需要对此进行迭代,因为它也是obj