Skip to content

Instantly share code, notes, and snippets.

@moderation
Created January 28, 2011 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moderation/799672 to your computer and use it in GitHub Desktop.
Save moderation/799672 to your computer and use it in GitHub Desktop.
{
"user": {
"profile_text_color": "333333",
"url": null,
"listed_count": 4,
"created_at": "Tue Jun 10 13:03:54 +0000 2008",
"profile_sidebar_fill_color": "efefef",
"screen_name": "virgiliocorrado",
"contributors_enabled": false,
"profile_background_tile": true,
"time_zone": "Eastern Time (US & Canada)",
"notifications": null,
"favourites_count": 59,
"lang": "en",
"profile_link_color": "009999",
"show_all_inline_media": false,
"following": null,
"geo_enabled": false,
"profile_sidebar_border_color": "eeeeee",
"description": "",
"id_str": "15072741",
"statuses_count": 25004,
"friends_count": 507,
"profile_use_background_image": true,
"protected": false,
"location": "the lightbulb moment centre",
"follow_request_sent": null,
"profile_background_color": "01090d",
"name": "virgiliocorrado",
"is_translator": false,
"profile_background_image_url": "http:\/\/a2.twimg.com\/a\/1295051201\/images\/themes\/theme14\/bg.gif",
"id": 15072741,
"verified": false,
"utc_offset": -18000,
"followers_count": 231,
"profile_image_url": "http:\/\/a0.twimg.com\/profile_images\/1128820290\/crabn_normal.jpg"
},
"in_reply_to_screen_name": "ginatrapani",
"in_reply_to_status_id": null,
"created_at": "Thu Jan 27 20:13:55 +0000 2011",
"geo": null,
"retweeted": false,
"text": "@ginatrapani @jeffjarvis @leolaporte #TWIG topic? Google's Schmidt wants to set the record straight http:\/\/j.mp\/gc6y6Z http:\/\/is.gd\/6vHdJa",
"source": "\u003Ca href=\"http:\/\/www.tweetdeck.com\" rel=\"nofollow\"\u003ETweetDeck\u003C\/a\u003E",
"in_reply_to_status_id_str": null,
"id_str": "30720175628099584",
"entities": {
"user_mentions": [{
"indices": [0, 12],
"screen_name": "ginatrapani",
"id_str": "930061",
"name": "Gina Trapani",
"id": 930061
},
{
"indices": [13, 24],
"screen_name": "jeffjarvis",
"id_str": "11435642",
"name": "Jeff Jarvis",
"id": 11435642
},
{
"indices": [25, 36],
"screen_name": "leolaporte",
"id_str": "3829151",
"name": "Leo Laporte",
"id": 3829151
}],
"urls": [{
"expanded_url": null,
"url": "http:\/\/j.mp\/gc6y6Z",
"indices": [100, 118]
},
{
"expanded_url": null,
"url": "http:\/\/is.gd\/6vHdJa",
"indices": [119, 138]
}],
"hashtags": [{
"indices": [37, 42],
"text": "TWIG"
}]
},
"contributors": null,
"in_reply_to_user_id_str": "930061",
"place": null,
"coordinates": null,
"retweet_count": 0,
"truncated": false,
"in_reply_to_user_id": 930061,
"favorited": false,
"id": 30720175628099584
}
type Hashtags struct {
Indices []int
Text string
}
type Urls struct {
Url string
Indices []int
Display_url string
Expanded_url string
}
type User_mentions struct {
Indices []int
Screen_name string
Id_str string
Name string
Id int64
}
type Entities struct {
Hashtags *Hashtags
Urls *Urls
User_mentions *User_mentions
}
type User struct {
Lang string
Verified bool
Followers_count int
Location string
Screen_name string
Following bool
Friends_count int
Profile_background_color string
Favourites_count int
Description string
Notifications string
Profile_text_color string
Url string
Time_zone string
Statuses_count int
Profile_link_color string
Geo_enabled bool
Profile_background_image_url string
Protected bool
Contributors_enabled bool
Profile_sidebar_fill_color string
Name string
Profile_background_tile string
Created_at string
Profile_image_url string
Id int64
Id_str string
Utc_offset int
Profile_sidebar_border_color string
}
type Tweet struct {
Text string
Truncated bool
Geo string
In_reply_to_screen_name string
Favorited bool
Source string
Contributors string
In_reply_to_status_id string
In_reply_to_user_id int64
Id int64
Created_at string
Entities *Entities
User *User
}
@moderation
Copy link
Author

The Entities section is where I hit trouble. I suspect that I need a map for the the hashtags, url's and user mentions sections.

JSON objects only support strings as keys; to encode a Go map type it must be of the form map[string]T (where T is any Go type supported by the json package).

Via http://blog.golang.org/2011/01/json-and-go.html

Go structures taken from https://github.com/hoisie/twitterstream/blob/master/types.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment