Skip to content

Instantly share code, notes, and snippets.

@bcherry
Created October 21, 2010 00:16
Show Gist options
  • Save bcherry/637634 to your computer and use it in GitHub Desktop.
Save bcherry/637634 to your computer and use it in GitHub Desktop.
adaptive function for the new string IDs for Twitter API objects (Snowflake)
// adaptive function for the new string IDs for Twitter API objects (Snowflake)
function useStringIdentifier(obj, property) {
var property_str = property + "_str";
if (!obj) {
return;
}
if (obj[property_str]) {
obj[property] = obj[property_str].toString();
delete obj[property_str];
} else if (obj[property]) {
obj[property] = obj[property].toString();
}
}
// example usage
getTweetsFromAjax(function(tweets) {
for (var i = 0; i < tweets.length; i++) {
useStringIdentifier(tweets[i], "id");
useStringIdentifier(tweets[i], "in_reply_to_status_id");
}
// do whatever with the tweets
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment