Created
October 21, 2010 00:16
-
-
Save bcherry/637634 to your computer and use it in GitHub Desktop.
adaptive function for the new string IDs for Twitter API objects (Snowflake)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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