Deserialize JSON with C#

前端 未结 10 1464
一生所求
一生所求 2020-11-21 05:57

I\'m trying to deserialize a Facebook friend\'s Graph API call into a list of objects. The JSON object looks like:

{\"data\":[{\"id\":\"518523721\",\"name\"         


        
10条回答
  •  礼貌的吻别
    2020-11-21 06:24

    Very easily we can parse JSON content with the help of dictionary and JavaScriptSerializer. Here is the sample code by which I parse JSON content from an ashx file.

    var jss = new JavaScriptSerializer();
    string json = new StreamReader(context.Request.InputStream).ReadToEnd();
    Dictionary sData = jss.Deserialize>(json);
    string _Name = sData["Name"].ToString();
    string _Subject = sData["Subject"].ToString();
    string _Email = sData["Email"].ToString();
    string _Details = sData["Details"].ToString();
    

提交回复
热议问题