Consider this status:

http://twitter.com/primerano/status/1784283306

The JSON for this, as found at http://twitter.com/statuses/show/1784283306.json,
is below (prettified by JSONLint - which, by the way, calls it valid).
Both Crack and ActiveSupport::JSON refuse to parse it, returning the
error "Invalid JSON string". Can anyone see why? My first thought was
the emoticon in the status text, ":-\", but even with that removed the
parsers fail.

Console:
>> json_string = <<EOS
{
    "text": "loving that I turned my 22 inch monitor  sideways.  great
for reading pdfs but the sta
nd doesn't support this configuration.",
    "in_reply_to_status_id": null,
    "user": {
        "description": "web geek, accomplishment junkie, parent and
System Architect at AOL",
        "time_zone": "Eastern Time (US & Canada)",
        "utc_offset": -18000,
        "profile_sidebar_fill_color": "e0ff92",
        "following": 0,
        "favourites_count": 0,
        "profile_sidebar_border_color": "87bc44",
        "profile_background_tile": true,
        "followers_count": 146,
        "url": "http:\/\/tonycode.com\/",
        "name": "Tony Primerano",
        "protected": false,
        "friends_count": 112,
        "profile_background_color": "9ae4e8",
        "created_at": "Fri Jun 22 20:36:59 +0000 2007",
        "notifications": false,
        "statuses_count": 1973,
        "profile_background_image_url": "http:\/\/s3.amazonaws.com\/
twitter_production\/profile_bac
kground_images\/1259422\/pattern2.JPG",
        "profile_text_color": "000000",
        "profile_image_url": "http:\/\/s3.amazonaws.com\/
twitter_production\/profile_images\/745684
29\/fire-1_normal.jpg",
        "location": "DC Area",
        "id": 7023582,
        "profile_link_color": "0000ff",
        "screen_name": "primerano"
    },
    "in_reply_to_user_id": null,
    "favorited": false,
    "in_reply_to_screen_name": null,
    "created_at": "Wed May 13 13:33:03 +0000 2009",
    "id": 1784283306,
    "truncated": false,
    "source": "<a href=\"http:\/\/www.tweetdeck.com\/\">TweetDeck<\/
a>"
}
EOS
>> Crack::JSON.parse(json_string)
Crack::ParseError: Invalid JSON string
        from /usr/lib/ruby/gems/1.8/gems/crack-0.1.1/lib/crack/json.rb:
14:in `parse'
        from (irb):40
>> ActiveSupport::JSON.decode(json_string)
ActiveSupport::JSON::ParseError: Invalid JSON string
        from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/json/decoding.rb:14:in `decode'
        from (irb):41

Reply via email to