zoukankan      html  css  js  c++  java
  • JSON数组成员反序列化

    场景:

    构想客户端能够传递如下格式JSON字符串到服务端:

    {"KeyValueSetList":[{"SN":"RQ1001","KeyValueList":[{"Key":"money","Value":"1000","Encode":0}]},{"SN":"RQ1002","KeyValueList":[{"Key":"money","Value":"2000","Encode":0}]}]}

    分析:

    这是一个拥有数组成员对象的JSON字符串

    服务端针对JSON格式创建相应对象

    public class KeyValue
        {
            public string Key { get; set; }
            public string Value { get; set; }
            public int Encode { get; set; }
            //public Dictionary<string,object> ToDictionary(List<KeyValue>)
        }
        public class KeyValueSet {
            public List<KeyValue> KeyValueList { get; set; }
            public string SN { get; set; }    
        }
        public class KeyValueSetWrap
        {
            public List<KeyValueSet> KeyValueSetList { get; set; }
        }

    ///Newtonsoft反射

     public static  T Deserialize<T>(string json)
        {
            T t= JsonConvert.DeserializeObject<T>(json);

            return t;

      }

  • 相关阅读:
    补充 函数详解
    Python web前端 11 form 和 ajax
    进程线程之间的通信
    面向对象epoll并发
    socket发送静态页面
    进程与线程的表示,属性,守护模式
    并发
    django, tornado
    并行
    非阻塞套接字编程, IO多路复用(epoll)
  • 原文地址:https://www.cnblogs.com/jeffry/p/5467785.html
Copyright © 2011-2022 走看看