Json数据:
{ "dataSet": { "header": { "returnCode": "0", "errorInfo": "HTTP请求错误", "version": "V1.0R010", "totalRows": "2000", "returnRows": "20" }, "fieldDefine": { "assetId": "string", "serverIdcId": "int", "inputTime": "datetime" }, "data": { "row": [ { "AssetId": "TCNS2006888", "ServerIdcId": "1", "InputTime": "2008-12-12" }, { "AssetId": "TCNS2006889", "ServerIdcId": "2", "InputTime": "2008-1-1" } ] } } }
将json数据转成dictionary的代码:
//实例化JavaScriptSerializer类的新实例 JavaScriptSerializer jss = new JavaScriptSerializer(); //将指定的 JSON 字符串转换为 Dictionary<string, object> 类型的对象 return jss.Deserialize<Dictionary<string, object>>(jsonData);