Monday, April 4, 2011

[twitter-dev] FireFix JSON parsing error? "id" != "id_str" in FireFox/jQuery?

Just noticed that on a whole lot of tweets I am retrieving through the
Twitter Search API that the tweet "id" numeric value is not equal to
the "id_str" value when JSON is turned in to JavaScript objects.

For example, the following JSON was just recently retrieved from
Twitter Search API using search term "#scala" -- note that both "is"
and "id_str" values evaluate to 54960878524710913 (numeric and string,
respectively):

{
"from_user_id_str": "65831",
"profile_image_url": "http://a3.twimg.com/profile_images/
1257814978/eightbit-0e7493d6-6ebd-45ae-a5a9-145b181f1971_normal.png
",
"created_at": "Mon, 04 Apr 2011 17:37:49 +0000",
"from_user": "torbjornvatn",
"id_str": "54960878524710913",
"metadata": {
"result_type": "recent"
},
"to_user_id": null,
"text": "RT @skskytteren: Had my first day as a professional
#scala #lift developer today. This is going to be so #great:-D",
"id": 54960878524710913,
"from_user_id": 65831,
"geo": null,
"iso_language_code": "en",
"to_user_id_str": null,
"source": "<a href="http://twitter.com/"
rel="nofollow">Twitter for iPhone</a>"
}

When I parse this JSON in FireFox, however, I get different values of
id and id_str in the resultant JavaScript object:

val jsobj = //...the JSON above
console.log(jsobj.id); // prints incorrect value 54960878524710910
console.log(jsobj.is_str); // prints correct value "54960878524710913"

Anyone got an idea what's going on here? Recently I've noticed a few
different web pages that with links to individual tweets failing,
including my own web application. I'm almost positive the source of
the problem is this incorrect parsing/interpretation of numeric
values.

Anyone seen anything similar happen?

And can anyone confirm/deny the issue on their local system using the
JSON above?

Brian Maso

--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements
Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk

No comments:

Post a Comment