[2.2.0] JSON error unexpected character at offset 0

347 views
Skip to first unread message

sebastien requiem

unread,
Oct 19, 2010, 10:22:21 PM10/19/10
to rhomobile
Hej guys,


I am actually using Rhodes to get a Public Timeline from Twitter.


Here is a simplified code sample :

res = Rho::AsyncHttp.get( :url => 'http://search.twitter.com/
search.json?q=<qword here>' )
puts res['body']
parsed = Rho::JSON.parse(res['body'])



And here is my output :

APP| {"results"=>[{"profile_image_url"=>"http://a0.twimg.com/
profile_images/832826388/me_before_normal.JPG", "created_at"=>"Mon, 18
Oct 2010 16:36:09 +0000", "from_user"=>"kiddouk",
"metadata"=>{"result_type"=>"recent"}, "to_user_id"=>nil, "text"=>"no,
you really haven't seen it. #nmd2010", "id"=>27750683143,
"from_user_id"=>17556, "geo"=>nil, "iso_language_code"=>"en",
"source"=>"&lt;a href=&quot;http://www.tweetdeck.com&quot;
rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;"}],
"max_id"=>27886331883, "since_id"=>0, "refresh_url"=>"?
since_id=27886331883&q=nmd2010", "results_per_page"=>15, "page"=>1,
"completed_in"=>0.01512, "query"=>"nmd2010"}
RJSON| rjson_tokener_parse_ex: error unexpected character at offset 0;
String:
RJSON| Incorrect json body.Error:JSON error code: 4; Offset: 0



Any idea on why I get such an error ?



regards,

evgeny vovchenko

unread,
Oct 20, 2010, 3:07:19 AM10/20/10
to rhom...@googlegroups.com
Looks like you got empty body from network

Hej guys,

regards,

--
You received this message because you are subscribed to the Google Groups
"rhomobile" group.
To post to this group, send email to rhom...@googlegroups.com.
To unsubscribe from this group, send email to
rhomobile+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rhomobile?hl=en.

sebastien requiem

unread,
Oct 20, 2010, 6:31:59 AM10/20/10
to rhomobile
In fact, as search.twitter.com puts the Content-type to JSON, I've
figured out that
res['body'] is ALREADY parsed by the JSON framework.


regards,


On Oct 20, 3:07 pm, "evgeny vovchenko" <evgenyvovche...@gmail.com>
wrote:
> Looks like you got empty body from network
>
>
>
> -----Original Message-----
> From: rhom...@googlegroups.com [mailto:rhom...@googlegroups.com] On
>
> Behalf Of sebastien requiem
> Sent: Wednesday, October 20, 2010 6:22 AM
> To: rhomobile
> Subject: [rhomobile] [2.2.0] JSON error unexpected character at offset 0
>
> Hej guys,
>
> I am actually using Rhodes to get a Public Timeline from Twitter.
>
> Here is a simplified code sample :
>
> res = Rho::AsyncHttp.get( :url => 'http://search.twitter.com/
> search.json?q=<qword here>' ) puts res['body'] parsed =
> Rho::JSON.parse(res['body'])
>
> And here is my output :
>
> APP| {"results"=>[{"profile_image_url"=>"http://a0.twimg.com/
> profile_images/832826388/me_before_normal.JPG", "created_at"=>"Mon, 18 Oct
> 2010 16:36:09 +0000", "from_user"=>"kiddouk",
> "metadata"=>{"result_type"=>"recent"}, "to_user_id"=>nil, "text"=>"no, you
> really haven't seen it. #nmd2010", "id"=>27750683143, "from_user_id"=>17556,
> "geo"=>nil, "iso_language_code"=>"en", "source"=>"&lt;a
> href=&quot;http://www.tweetdeck.com"
Reply all
Reply to author
Forward
0 new messages