如何在aspx中显示JSON结果?

时间:2016-03-28 09:47:46

标签: asp.net json

我有JSON link  并希望通过使用具有不同参数值的此类链接在我的网站页面中显示记录。

1 个答案:

答案 0 :(得分:0)

试试这个:

使用System.Web.Script.Serialization;

 string a = "{\"data\":[{\"ID\":1,\"MANUFACTURER\":\"Central Semiconductor Corp\",\"PRODUCT_NAME\":\"CEDM7001\",\"REPTYPE\":\"similar\"},{\"ID\":2,\"MANUFACTURER\":\"Central Semiconductor Corp\",\"PRODUCT_NAME\":\"CEDM7001E\",\"REPTYPE\":\"similar\"},{\"ID\":3,\"MANUFACTURER\":\"Central Semiconductor Corp\",\"PRODUCT_NAME\":\"SSM3K16CT\",\"REPTYPE\":\"direct\"}]}";
    JavaScriptSerializer js = new JavaScriptSerializer();
    dynamic b = js.DeserializeObject(a);
    dynamic[] c = b["data"];
    for (int i = 0; i < c.Length; i++)
    {
        string ID =Convert.ToString(c[i]["ID"]);
        string MANUFACTURER = Convert.ToString(c[i]["MANUFACTURER"]);
        string PRODUCT_NAME = Convert.ToString(c[i]["PRODUCT_NAME"]);
        string REPTYPE = Convert.ToString(c[i]["REPTYPE"]);
    }