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
  • 相关阅读:
    征战蓝桥 —— 2016年第七届 —— C/C++A组第5题——消除尾一
    UVA 10410 Tree Reconstruction (树重建)
    UVA 12166 Equilibrium Mobile (修改天平)(dfs字符串表示的二叉树)
    UVA 1600 Patrol Robot (巡逻机器人)(bfs)
    UVA 712 STrees(S树)
    UVA 536 Tree Recovery (二叉树重建)
    Stall Reservations【贪心】【堆】
    Sunscreen【贪心】
    Sunscreen【贪心】
    Sunscreen【贪心】
  • 原文地址:https://www.cnblogs.com/wang-123/p/7017196.html
Copyright © 2011-2022 走看看