DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Ruby Object To JavaScript Object
Convert a Ruby object to a JavaScript object.
Requires Rails and prototype.js
javascript_object = "<%=
ruby_object.to_json.gsub('\\','\\\\\\\\').gsub('"', '\\"')
%>".evalJSON()






Comments
Snippets Manager replied on Wed, 2008/07/23 - 8:43am
json = ruby_object.to_json