C# Newtonsoft.Json 使用

            byte[] bUserInfoSearch = new byte[1024 * 10]; //10kb大小
            Marshal.Copy(lpBuffer, bUserInfoSearch, 0, bUserInfoSearch.Length);
            string strUserInfoSearch = System.Text.Encoding.UTF8.GetString(bUserInfoSearch);

            CUserInfoSearch  m_JsonUserInfoSearch = new CUserInfoSearch();
            //序列化这个字符串
            m_JsonUserInfoSearch = JsonConvert.DeserializeObject<CUserInfoSearch>(strUserInfoSearch);
     public class CUserInfoSearch
        {
            public CUserInfoSearchContent UserInfoSearch { get; set; }
        }
        public class CUserInfoSearchContent
        {
            public string searchID { get; set; }
public string responseStatusStrg { get; set; } //查询状态字符串描述: OK-查询结束, MORE-还有数据等待查询, NO MATCH-没有匹配数据
            public int numOfMatches { get; set; } //本次返回的记录条数
         
public int totalMatches { get; set; } //符合条件的记录总条数
public List<CUserInfoContent> UserInfo { get; set; } }
  public class CUserInfoContent
        {
            public string employeeNo { get; set; }
            public string name { get; set; }
            public string userType { get; set; }
            public bool closeDelayEnabled { get; set; }
            public CVaild Valid { get; set; }
            public string belongGroup { get; set; }
            public string password { get; set; }
            public string doorRight { get; set; }
            public List<CRightPlan> RightPlan { get; set; }
            public int maxOpenDoorTime { get; set; }
            public int openDoorTime { get; set; }
            public int roomNumber { get; set; }
            public int floorNumber { get; set; }
            public bool doubleLockRight { get; set; }
            public bool alwaysOpenRight { get; set; }
            public bool localUIRight { get; set; }
            public string userVerifyMode { get; set; }
            public bool checkUser { get; set; }
        }
        public class CVaild
        {
            public bool enable { get; set; }
            public string beginTime { get; set; }
            public string endTime { get; set; }
            public string timeType { get; set; }
        }
       public class CRightPlan
        {
            public int doorNo { get; set; }
            public string planTemplateNo { get; set; }
        }

json字符串为

{
    "UserInfoSearch":    {
        "searchID":    "1",
        "responseStatusStrg":    "MORE",
        "numOfMatches":    2,
        "totalMatches":    4,
        "UserInfo":    [{
                "employeeNo":    "1",
                "name":    "管理员(131374",
                "userType":    "normal",
                "closeDelayEnabled":    false,
                "Valid":    {
                    "enable":    false,
                    "beginTime":    "0-00-00T00:00:00",
                    "endTime":    "0-00-00T00:00:00",
                    "timeType":    "local"
                },
                "belongGroup":    "",
                "password":    "",
                "doorRight":    "1",
                "RightPlan":    [{
                        "doorNo":    1,
                        "planTemplateNo":    "1"
                    }],
                "maxOpenDoorTime":    0,
                "openDoorTime":    0,
                "roomNumber":    1,
                "floorNumber":    1,
                "localUIRight":    false,
                "numOfCard":    0,
                "numOfFP":    0,
                "numOfFace":    0
            }, {
                "employeeNo":    "2",
                "name":    "123456",
                "userType":    "normal",
                "closeDelayEnabled":    false,
                "Valid":    {
                    "enable":    false,
                    "beginTime":    "0-00-00T00:00:00",
                    "endTime":    "0-00-00T00:00:00",
                    "timeType":    "local"
                },
                "belongGroup":    "",
                "password":    "",
                "doorRight":    "1",
                "RightPlan":    [{
                        "doorNo":    1,
                        "planTemplateNo":    "1"
                    }],
                "maxOpenDoorTime":    0,
                "openDoorTime":    0,
                "roomNumber":    1,
                "floorNumber":    1,
                "localUIRight":    false,
                "numOfCard":    0,
                "numOfFP":    0,
                "numOfFace":    1
            }]
    }
}

猜你喜欢

转载自www.cnblogs.com/enych/p/12485366.html