#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
/// <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