Re: Sortable List, Serializing and Parsing with Ruby

Justin Perkins
Wed, 30 Jan 2008 18:48:18 -0000

On Jan 30, 2008 10:40 AM, OmenKing
<omen.king-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