Main criteria is ease of manipulation and portability.
2 Answers
JSON would be my choice, easy to generate in javascript and just as easy to parse directly into a hash in Ruby.
Ruby (irb session):
>> require 'json'
=> true
>> {:name => 'Chris Cherry', :emails => ['[email protected]', '[email protected]']}.to_json
=> "{"emails":["[email protected]","[email protected]"],"name":"Chris Cherry"}"
>> json_string = _
=> "{"emails":["[email protected]","[email protected]"],"name":"Chris Cherry"}"
>> JSON.parse(json_string)
=> {"name"=>"Chris Cherry", "emails"=>["[email protected]", "[email protected]"]}
Comments
Since you are using rails, you can take advantage of the fact that ActiveSupport has JSON support.
ruby-1.9.2-p136 :003 > j = ActiveSupport::JSON
=> ActiveSupport::JSON
ruby-1.9.2-p136 :004 > j.encode({:team => "Celtics", :players => "20"})
=> "{\"team\":\"Celtics\",\"players\":\"20\"}"
ruby-1.9.2-p136 :005 > j.decode("{\"team\":\"Celtics\",\"players\":\"20\"}")
=> {"team"=>"Celtics", "players"=>"20"}