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
  • 相关阅读:
    二叉树的建树,按层遍历,结点总数,页结点,深度以及三序非递归遍历二叉树,建立中序线索二叉树
    志愿者选拔(单调队列)
    重建二叉树(中后序求前序)
    New Year Table(几何)
    Hopscotch(细节)
    红黑树(中序二叉树)
    Linux-awk命令详解
    Python--常用模块
    Python--re模块
    Python--模块与包
  • 原文地址:https://www.cnblogs.com/wang-123/p/7017196.html
Copyright © 2011-2022 走看看