JSON object causing exception with Rails JSON.decode -


the json object below causes activesupport::json.decode throw exception below. causes this?

exception:

795: unexpected token @ '' /usr/local/lib/ruby/gems/1.9.1/gems/json-1.8.1/lib/json/common.rb:155:in `parse' /usr/local/lib/ruby/gems/1.9.1/gems/json-1.8.1/lib/json/common.rb:155:in `parse' /usr/local/lib/ruby/gems/1.9.1/gems/multi_json-1.9.2/lib/multi_json/adapters/json_common.rb:16:in `load' /usr/local/lib/ruby/gems/1.9.1/gems/multi_json-1.9.2/lib/multi_json/adapter.rb:20:in `load' /usr/local/lib/ruby/gems/1.9.1/gems/multi_json-1.9.2/lib/multi_json.rb:121:in `load' /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/json/decoding.rb:15:in `decode' 

json object (from https://itunes.apple.com/us/lookup?id=972909677):

{  "resultcount":1,  "results": [ {"artistviewurl":"https://itunes.apple.com/us/artist/twitter-inc./id296415947?uo=4", "artworkurl60":"http://is2.mzstatic.com/image/pf/us/r30/purple5/v4/08/c5/cf/08c5cf4e-876f-8518-d23e-6d2e4b24694b/appicon60x60_u00402x.png",  "screenshoturls":["http://a3.mzstatic.com/us/r30/purple3/v4/13/a1/86/13a18611-ba42-d9fe-38a2-3c5b03db7543/screen1136x1136.jpeg", "http://a2.mzstatic.com/us/r30/purple3/v4/f3/4c/68/f34c68fe-7284-d094-00ef-49bd66e53851/screen1136x1136.jpeg", "http://a1.mzstatic.com/us/r30/purple3/v4/9c/1a/c3/9c1ac3c8-cf2c-99cf-87f4-beb9d0962e83/screen1136x1136.jpeg", "http://a3.mzstatic.com/us/r30/purple6/v4/12/25/a5/1225a5e4-224f-04c6-6ca9-350b4d348aaa/screen1136x1136.jpeg"], "ipadscreenshoturls":[], "artworkurl512":"http://is5.mzstatic.com/image/pf/us/r30/purple3/v4/23/52/7b/23527b98-654b-4dab-9352-4359f1a5e541/mzl.icaayech.jpg", "kind":"software", "features":[],  "supporteddevices":["ipadfourthgen4g", "iphone6", "ipad23g", "iphone5s", "ipadmini", "iphone6plus", "ipad2wifi", "iphone4s", "iphone5", "ipadfourthgen", "iphone4", "ipodtouchfifthgen", "ipadthirdgen", "ipadthirdgen4g", "ipadmini4g", "iphone5c"], "advisories":[], "isgamecenterenabled":false, "trackcensoredname":"periscope", "trackviewurl":"https://itunes.apple.com/us/app/periscope/id972909677?mt=8&uo=4", "contentadvisoryrating":"4+", "artworkurl100":"http://is5.mzstatic.com/image/pf/us/r30/purple3/v4/23/52/7b/23527b98-654b-4dab-9352-4359f1a5e541/mzl.icaayech.jpg", "languagecodesiso2a":["nb", "ca", "cs", "da", "nl", "en", "fr", "de", "el", "id", "it", "ja", "ko", "nn", "pl", "pt", "ru", "zh", "es", "sv", "zh", "tr", "uk", "vi"], "filesizebytes":"15090739", "sellerurl":"https://periscope.tv", "averageuserratingforcurrentversion":3.5, "userratingcountforcurrentversion":166, "trackcontentrating":"4+", "currency":"usd", "wrappertype":"software", "version":"1.0.2",  "description":"periscope lets broadcast live video world. going live instantly notify followers can join, comment , send hearts in real time. more hearts get, higher flutter on screen.\n\nother features:\n[+] replay: when broadcast over, can make available replay viewers can watch later. viewers can replay broadcast comments , hearts relive full experience. replays last 24 hours. can delete replay @ time.\n[+] private: if want broadcast specific people, press lock icon before going live , choose want invite broadcast. \n[+] twitter: can choose share periscope broadcasts on twitter tapping bird icon before start broadcasting. when go live, you’ll tweet link twitter followers can watch on web (or in app)\n[+] manage notifications: periscope suggest people follow based on twitter network. can follow new people, or unfollow them if don’t want notified when go live. can adjust notification preferences in periscope settings (in profile)\n[+] hearts: periscope keeps track of how many hearts viewers. more hearts, higher in “most loved” list.", "artistid":296415947, "artistname":"twitter, inc.", "genres":["social networking"], "price":0.00, "bundleid":"com.bountylabs.periscope", "genreids":["6005"], "releasedate":"2015-03-26t07:01:50z", "sellername":"twitter, inc.", "trackname":"periscope", "trackid":972909677, "primarygenrename":"social networking", "primarygenreid":6005,  "releasenotes":"- new ‘global’ section added periscope lists recent, live broadcasts around world. home feed show live broadcasts , replays tailored you.\n- new “follower only” mode available before starting broadcast. if turn on, viewers follow can comment in broadcast.\n- users verified marked classic twitter verified badge you’re used seeing.\n- major scrolling performance improvements. feel silky , smooth compared last version!\n- can block users more (tap on comment present option block)\n- fixed bug viewers & broadcasters stop seeing comments , hearts.\n- fixed caching issue wrong profile image displayed user\n- fixed bug ios 7 users couldn’t watch broadcasts kajillions of viewers", "minimumosversion":"7.1", "formattedprice":"free", "userratingcount":949, "averageuserrating":3.5}] } 

request code:

    id_string = a.join ','      # make request itunes api     uri = uri.parse itunes_url + id_string     http = net::http.new uri.host, uri.port     http.use_ssl = true     http.verify_mode = openssl::ssl::verify_none     req = net::http::get.new uri.request_uri     resp = http.request req      # json string -> hash     logger.info "+++ decoding #{uri}"     resp_hash = activesupport::json.decode resp.body.strip 

output of resp.body.strip:

]p?na      ??+??@ ?u)s ??cΞ/???n?#?)ʿ?=" ?m?gf?b??b"x?Ї]?`nx5z?g+Éo{?lj?d7|???~?3)???????u?rk?@?????w[8?%r:+?v??z@+lx?l?tcb?0?e?u?zq^z??ק?-??5bnsj?a?yo ?i?5Н$ʩv-t?sj??_~?nݭ?                                                                                         u?'?l??x 9?3 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -