//开始解析
//引用
//using System.Web.Script.Serialization;
JavaScriptSerializer js = new JavaScriptSerializer();
Dictionary<string, Object> oList = js.DeserializeObject("Json字符串") as Dictionary<string, Object>;
if (oList != null)
{
string strRet = "";
if (oList.ContainsKey("ret"))
{
strRet = oList["ret"].ToString();
}
if (strRet == "0")
{
Dictionary<string, object> oDataList = oList["data"] as Dictionary<string, Object>;
object[] oItem_listData = oDataList["item_list"] as object[];
if (oItem_listData != null)
{
System.Linq.IOrderedEnumerable<object> q = from a in oItem_listData orderby ((Dictionary<string, object>)a)["字段"].ToString() descending select a;//排序的
foreach (var oObj in q)
{
Dictionary<string, object> oCountriesDataList = oObj as Dictionary<string, object>;
//匹配到Json串的内容 同过实体依次赋值
if (oCountriesDataList .ContainsKey("类型"))
{
类型= oCountriesDataList ["类型"].ToString();
}
if (oCountriesDataList .ContainsKey("内容"))
{
内容= oCountriesDataList ["内容"].ToString();
}
//如果 内容里面 还有下一级别的话 则继续往下面解析 Json
object[] DateList = oCountriesDataList ["内容"] as object[];
if (DateList != null)
{
System.Linq.IOrderedEnumerable<object> qp = from a in DateList orderby ((Dictionary<string, object>)a)["时间"].ToString() ascending select a;//时间排序
foreach (var oObj1 in qp)
{
Dictionary<string, object> LowesDataList = oObj1 as Dictionary<string, object>;//数据集合
//得到里面 对用的 内容
DateTime Date = DateTime.Parse(LowesDataList ["时间"].ToString()); //日期
//你的类 继续赋值 add
}
}
}
}
原文地址:https://www.cnblogs.com/goodluckily/p/11027475.html