C#解析json方法整理

下面举个简单的例子,从项目中修改过来的部分:

引用:using System.Web.Script.Serialization;


string jsonSrc = "{info:[{id:1,name:'xiaohu'},{id:2,name:'ming'},{id:3,name:'zhou'}]}";

JavaScriptSerializer jsz = new JavaScriptSerializer();
Dictionary<string, object> jsonData = (Dictionary<string, object>)jsz.DeserializeObject(jsonSrc);
object[] rows = (object[])result["info"];
Dictionary<string, object> val;

string text = "";
foreach (object ob in rows)
{

      Dictionary<string, object> val = (Dictionary<string, object>)ob;
      text += val["id"].ToString();
      text += ",";
      text += val["name"].ToString();
      text += "|";
}

你可能感兴趣的:(.net,.net,.net)