示例#1
0
        public RedditPost GetPosts(string subreddit)
        {
            string     data = GetAPIJson(subreddit);
            RedditPost aww  = JsonConvert.DeserializeObject <RedditPost>(data);

            return(aww);
        }
示例#2
0
        public RedditPost GetPost(string subreddit)
        {
            string  output = GetAPIJson(subreddit);
            JObject json   = JObject.Parse(output);
            //jobject is special object designed to work with JSON, lets you manually go in and filter out your JSON
            List <JToken> modelData = json["data"]["children"].ToList();

            //filtered down to data, down to children, go into children, select particular set of data
            //narrowed down to what's relevant for the model
            RedditPost rp = JsonConvert.DeserializeObject <RedditPost>(modelData[3]["data"].ToString());

            return(rp);
        }