#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