Litjson Read Data sample

Source: Internet
Author: User

  This article mainly introduces the Litjson read data samples, we refer to the use of the bar

1. Download and apply the Litjson,dll file   2. Build two classes;   code as follows:    public class Jsondata     {      & nbsp public string result {get; set;}         Public list<gamedata> info {get; set;}   &NBSP ; {          public gamedata ()         {}         #region Model         private int _id;         private string _dept;         private string _sid;         private string _oldsid;         private string _userid;         private string _roleid;         private string _rolename;         private string _rolelevel;         private string _gold;         private string _money;         private string _inittime;         private string _lastlogin;        private string _querytime;        ///<summary>        ///         ///< /summary>         public int ID         {          &N Bsp set {_id = value;}             get {return _id;}        }   &N Bsp    ///<summary>        ///platform number        ///</summary> &N Bsp       public string dept         {            set {_DEP t = value; {            get {return _dept;}        }       &NBSP ; <summary>        ///server number        ///</summary>     & nbsp   public string SID         {&NBsp           set {_sid = value;}             get {return _sid;} &N Bsp      }        ///<summary>        ///original server number   &NBS P    ///</summary>         public string oldsid         {  & nbsp         set {_oldsid = value;}             get {return _oldsid;} &NB Sp      }        ///<summary>        ///user platform ID   &nbsp ;    ///</summary>         public string userid         {  & nbsp         set {_userid = value;}             get {return _userid;} &NB Sp      }        ///<summary>        ///  &NBsp      ///</summary>         public string Roleid         {& nbsp           set {_roleid = value;}             get {return _roleid ; {       }        ///<summary>        ///role name        ///</summary>         public string rolename         {            set {_rolename = value;}             get {RET Urn _rolename; {       }        ///<summary>        ///role level &NBSP ;      ///</summary>         public string rolelevel         {            set {_rolelevel = value;}             GEt {return _rolelevel;}        }        ///<summary>     &NBSP ;  ///Gold        ///</summary>         public string gold   &NBSP ;     (            set {_gold = value;}             get {return _gold;}        }        ///<summary>        ///Silver        ///</summary>         public string $   &NBS P     (            set {_money = value;}           &NBSP ; get {return _money;}        }        ///<summary>        ///role creation time        ///</summary>         public string Inittime &nbs P       {            set {_inittime = value;}             GE t {return _inittime;}        }        ///<summary>        ///Last Login time        ///</summary>         public string Lastlogin &N Bsp       {            set {_lastlogin = value;}         & nbsp   get {return _lastlogin;}        }        ///<summary>   &NB Sp    ///query time        ///</summary>         public string Querytim E         {            set {_querytime = value;}             get {return _querytime;        }         #endregion Mode L       3. Read the data   code as follows:   string json_str = @ "{" "Result" ":" 1 "," "info": [{"Sid"] "" 2 "" "," "RoleName" "" PO cuibai "" "," "Roleid" ":" "900001" "," "Lastlogin" ":" "2014-01-08 10:54:52" "," "Inittime" "," "2013-11-15 12:01:05.0" "," "Money "": "" 867 "", "" Rolelevel "": "" 1 "", "" userid "": "" Athena "", "" Oldsid "": "" "," "," "", "", "", "", "", "" 9992837 "", "" Dept "", "" "", "" " Querytime ":" "2014-01-08 11:56:38" "},{" "Sid" ":" "2" "," "RoleName" ":" "poof" "," "Roleid" ":" "5700001" "," "Lastlogin" "" ":" " 2013-11-16 18:38:54 "," "Inittime" ":" "2013-11-16 18:25:45.0" "," "Money" ":" "0" "," "Rolelevel" ":" "" "," "userid" "" Athena "", "" Oldsid "": "" 1 "", "" Gold "": "" 0 "", "" Dept "": "", "" Querytime "": "" 2014-01-08 11:56:38 ""},{"" Sid "": "2" ", "RoleName" ":" "Huiguang" "," "Roleid" ":" "2800001" "," "Lastlogin" ":" 2013-11-15 15:00:07 "", "" Inittime "": "" 2013-11-15 14:59:25.0 "", "" Money "": "" 0 "", "" Rolelevel "": "" 1 "", "" userid "": "" Athena "", "" Oldsid "": "" 1 "", "" Gold "": "" 0 "", "" Dept " ":" "" "," "Querytime" ":" "2014-01-08 11:56:38" "}]}";                  gamewindowsservice.common.jsondata Jsondata = litjson.jsonmapper.toobject< Gamewindowsservice.common.jsondata> (JSON_STR);                   list<gamedata> gamedatalist = Jsondata.info;                 foreach (var gamedata in gamedatalist)                 {                    Common.Common.WriteFi Le (Gamedata.add (). ToString ());                }    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.