using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace NEducation.Code { public class History { public List listCourseHistory { get; set; } // parse data from JSON data public History() { } public History(string json) : this(JObject.Parse(json)) { } public History(JObject jObject) { if (jObject != null) { var list = jObject["LIST_COURSE_HIS"]; if (list != null && list.HasValues) { listCourseHistory = new List(); JArray a = (JArray)list; foreach (JObject o in a.Children()) { listCourseHistory.Add(new HistoryElement(o)); } } } } } public class HistoryElement { public string totalLesson { get; set; } public string totalLessonLearn { get; set; } public string percent { get; set; } public string id { get; set; } public string categoryId { get; set; } public string code { get; set; } public string name { get; set; } public string description { get; set; } public string introduction { get; set; } public string isLearn { get; set; } public string iconPath { get; set; } public string logoPath { get; set; } public string expDate { get; set; } // listLesson always null public string listLesson { get; set; } // parse data from JSON data public HistoryElement() { } public HistoryElement(string json) : this(JObject.Parse(json)) { } public HistoryElement(JObject jObject) { if (jObject != null) { totalLesson = (string)jObject["TOTAL_LESSON"]; totalLessonLearn = (string)jObject["TOTAL_LESSON_LEARN"]; percent = (string)jObject["PERCENT"]; description = (string)jObject["DESCRIPTION"]; iconPath = (string)jObject["ICON_PATH"]; id = (string)jObject["ID"]; categoryId = (string)jObject["CATEGORY_ID"]; code = (string)jObject["CODE"]; name = (string)jObject["NAME"]; introduction = (string)jObject["INTRODUCTION"]; isLearn = (string)jObject["IS_LEARN"]; logoPath = (string)jObject["LOGO_PAHT"]; expDate = (string)jObject["EXP_DATE"]; listLesson = (string)jObject["LIST_LESSON"]; } } } }