using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace NEducation.Code { public class Ranking { public List listRanking { get; set; } // parse data from JSON data public Ranking() { } public Ranking(string json) : this(JObject.Parse(json)) { } public Ranking(JObject jObject) { if (jObject != null) { var list = jObject["LIST_RANKING"]; if (list != null && list.HasValues) { listRanking = new List(); JArray a = (JArray)list; foreach (JObject o in a.Children()) { listRanking.Add(new RankingElement(o)); } } } } } public class RankingElement { public string seq { get; set; } public string usersId { get; set; } public string users { get; set; } public string msisdn { get; set; } public string serviceId { get; set; } public string fullName { get; set; } public string birthday { get; set; } public string picture { get; set; } public string totalScore { get; set; } // parse data from JSON data public RankingElement() { } public RankingElement(string json) : this(JObject.Parse(json)) { } public RankingElement(JObject jObject) { if (jObject != null) { seq = (string)jObject["SEQ"]; usersId = (string)jObject["USERS_ID"]; users = (string)jObject["USERS"]; msisdn = (string)jObject["MSISDN"]; serviceId = (string)jObject["SERVICE_ID"]; fullName = (string)jObject["FULLNAME"]; birthday = (string)jObject["BIRTHDAY"]; String myString = (string)jObject["BIRTHDAY"]; // get value from text field DateTime myDateTime = new DateTime(); myDateTime = DateTime.ParseExact(myString, "dd/MM/yyyy HH:mm:ss", null); String myString_new = myDateTime.ToString("dd-MM-yyyy"); birthday = myString_new; picture = (string)jObject["PICTURE"]; totalScore = (string)jObject["TOTAL_SCORE"]; } } } }