Re: Sortable List, Serializing and Parsing with Ruby

OmenKing
Wed, 30 Jan 2008 19:01:51 -0000

Even though JSON is really cool I''m not sure if thats what I need.
I have the Pragmatic Prototype and Scriptaculous book and in there
AJAX samples they didn''t need toJSON.
check out my pastie.

I just not sure how to work with serialized info once its passed to
webrick.


On Jan 30, 1:48 pm, "Justin Perkins"
<justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On Jan 30, 2008 10:40 AM, OmenKing
<omen.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > (1) serializing and passing with Ajax
>
> Try using toJSON() on the collection, like:
>
> tasks = $A([
>   { :id => 1, :name => ''Foo'' },
>   { :id => 2, :name => ''Bar'' },
> ]);
>
> tasks.toJSON()
>
> > Where are the %5B%5D coming from?
>
> Those are escaped characters. They need to be unescaped on the server.
>
> > (2) parsing it in ruby
>
> Since you''re not using Rails, which has handy helpers for dealing
with
> JSON, you need to include your own implementation to parse JSON or
> write your own.
>
> -justin