小编Let*_*ine的帖子

如何将JSON数组转换为List <>?

这是我的json,我需要访问出勤数组中每个对象下的值:

{"name":" ","course":"","attendance":[{"name":"INTERNATIONAL FINANCE","type":"Theory","conducted":"55","present":"50"},{"name":"INDIAN CONSTITUTION","type":"Theory","conducted":"6","present":"6"}]}
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

public class Att
{

    public class Attendance
    {
        public string name { get; set; }
        public string type { get; set; }
        public string conducted { get; set; }
        public string present { get; set; }
    }


    public Att(string json)
    {
        JObject jObject = JObject.Parse(json);
        JToken jUser = jObject;

        name = (string)jUser["name"];
        course = (string)jUser["course"];
        attender = jUser["attendance"].ToList<Attendance>;

    }

    public string name { get; set; }
    public string course { get; set; }
    public …
Run Code Online (Sandbox Code Playgroud)

c# json windows-phone

15
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

json ×1

windows-phone ×1