Deserializing a JSON file with JavaScriptSerializer()

后端 未结 6 1868
醉梦人生
醉梦人生 2020-12-01 17:30

the json file\'s structure which I will deserialize looks like below;

{
    \"id\" : \"1lad07\",
    \"text\" : \"test\",
    \"url\" : \"http:\\/\\/twitpic.         


        
6条回答
  •  日久生厌
    2020-12-01 18:35

    Create a sub-class User with an id field and screen_name field, like this:

    public class User
    {
        public string id { get; set; }
        public string screen_name { get; set; }
    }
    
    public class Response {
    
        public string id { get; set; }
        public string text { get; set; }
        public string url { get; set; }
        public string width { get; set; }
        public string height { get; set; }
        public string size { get; set; }
        public string type { get; set; }
        public string timestamp { get; set; }
        public User user { get; set; }
    }
    

提交回复
热议问题