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
  • 相关阅读:
    如何用Vault下载.Text 096的源代码
    新增QQ表情
    TortoiseCVS比WinCVS好用多了
    上周热点回顾(5.276.2)
    Couchbase的bug引起的缓存服务器CPU占用高
    云计算之路阿里云上:Linux内核bug引起的“黑色10秒钟”
    上周热点回顾(5.205.26)
    云计算之路阿里云上:拔云见日的那一刻,热泪盈眶
    云计算之路试用Azure:遭遇第一次故障
    上周热点回顾(5.135.19)
  • 原文地址:https://www.cnblogs.com/wang-123/p/7017196.html
Copyright © 2011-2022 走看看