jflect icon indicating copy to clipboard operation
jflect copied to clipboard

Minor Trouble with Reddit feeds

Open 011010101101 opened this issue 10 years ago • 0 comments

Hey str1ngs, thanks so much for jflect! It's incredibly useful.

Not sure if you are still interested in working on it, but thought I'd share this just in case? Here's a feed scraped from Reddit today:

https://storage.googleapis.com/bt-public/misc/jflect-sample.json

I included jflect's output below. To get golang to parse the feed, a couple changes are required:

  1. Edited must be changed from bool to interface{}. (That's because sometimes it's false and sometimes it's a float. Lame, I agree)
  2. Created and CreatedUtc must be changed from int to float64
type Reddit struct {
    Data struct {
        After    string `json:"after"`
        Children []struct {
            Data struct {
                Archived         bool          `json:"archived"`
                Author           string        `json:"author"`
                Clicked          bool          `json:"clicked"`
                Created          int           `json:"created"`
                CreatedUtc       int           `json:"created_utc"`
                Domain           string        `json:"domain"`
                Downs            int           `json:"downs"`
                Edited           bool          `json:"edited"`
                Gilded           int           `json:"gilded"`
                Hidden           bool          `json:"hidden"`
                Id               string        `json:"id"`
                IsSelf           bool          `json:"is_self"`
                MediaEmbed       struct{}      `json:"media_embed"`
                ModReports       []interface{} `json:"mod_reports"`
                Name             string        `json:"name"`
                NumComments      int           `json:"num_comments"`
                Over18           bool          `json:"over_18"`
                Permalink        string        `json:"permalink"`
                Saved            bool          `json:"saved"`
                Score            int           `json:"score"`
                SecureMediaEmbed struct{}      `json:"secure_media_embed"`
                Selftext         string        `json:"selftext"`
                Stickied         bool          `json:"stickied"`
                Subreddit        string        `json:"subreddit"`
                SubredditId      string        `json:"subreddit_id"`
                Thumbnail        string        `json:"thumbnail"`
                Title            string        `json:"title"`
                Ups              int           `json:"ups"`
                Url              string        `json:"url"`
                UserReports      []interface{} `json:"user_reports"`
                Visited          bool          `json:"visited"`
            } `json:"data"`
            Kind string `json:"kind"`
        } `json:"children"`
        Modhash string `json:"modhash"`
    } `json:"data"`
    Kind string `json:"kind"`
}

011010101101 avatar Jul 16 '15 08:07 011010101101