Deserialize JSON with C#

前端 未结 10 1478
一生所求
一生所求 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:16

    Serialization:

    // Convert an object to JSON string format
    string jsonData = JsonConvert.SerializeObject(obj);
    
    Response.Write(jsonData);
    

    Deserialization::

    To deserialize a dynamic object

      string json = @"{
          'Name': 'name',
          'Description': 'des'
        }";
    
    var res = JsonConvert.DeserializeObject< dynamic>(json);
    
    Response.Write(res.Name);
    

提交回复
热议问题