zoukankan      html  css  js  c++  java
  • 将json转为 SortedDictionary

     #region ConvertJsonToSortedDictionary 将json转为 SortedDictionary
            /// <summary>
            /// 将json转为 SortedDictionary
            /// </summary>
            /// <param name="json"></param>
            /// <returns></returns>
            public static ReturnValue ConvertJsonToSortedDictionary(string json)
            {
                ReturnValue retValue = new ReturnValue();
                if (string.IsNullOrEmpty(json))
                {
                    retValue.HasError = true;
                    retValue.Message = "json数据为空";

                    return retValue;
                }
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                try
                {
                    SortedDictionary<string, object> sortDict = new SortedDictionary<string, object>(javaScriptSerializer.Deserialize<SortedDictionary<string, object>>(json));

                    retValue.HasError = false;
                    retValue.ReturnObject = sortDict;
                    return retValue;
                }
                catch (Exception ex)
                {
                    retValue.HasError = true;
                    retValue.Message = "数据转换出错";
                    retValue.InnerMessage = ex.Message;

                    log.WarnFormat("ConvertJsonToSortedDictionary   json={0} 出错,原因:{1}", json, ex.Message);
                    return retValue;
                }
            }
            #endregion
  • 相关阅读:
    Junit连接oracle数据库
    java判断字符串是否由数字组成
    Hibernate各种主键生成策略与配置详解
    一对多映射关系
    one-to-one 一对一映射关系(转 wq群)
    工厂模式
    struts2
    创建JUtil
    jdbc
    压缩数据
  • 原文地址:https://www.cnblogs.com/wang-123/p/7017196.html
Copyright © 2011-2022 走看看