0

Main criteria is ease of manipulation and portability.

2 Answers 2

1

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]"]}
Sign up to request clarification or add additional context in comments.

Comments

1

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"}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.