예제 #1
0
        public RedditPost GetPost()
        {
            string        output    = GetAPIString("aww");
            JObject       json      = JObject.Parse(output);
            List <JToken> modelData = json["data"]["children"].ToList();
            //I want to put a for loop in here to display the list but I can't figure out how
            //I know that modelData[0] is restricting me to just the first index
            RedditPost rp = JsonConvert.DeserializeObject <RedditPost>(modelData[0]["data"].ToString());

            return(rp);
        }
예제 #2
0
        public RedditPost GetPost()
        {
            string output = GetAPIString("aww");

            //special collection used with Json data
            //useful when you have an API with an enormous amount of data
            JObject json = JObject.Parse(output);

            List <JToken> modelData = json["data"]["children"].ToList();
            string        s         = modelData[0]["data"].ToString();

            RedditPost rp = JsonConvert.DeserializeObject <RedditPost>(modelData[0]["data"].ToString());

            return(rp);
        }