I am trying to serialize and deserialize a hash. When the hash is canceled, the keys are de-symbolized; for example, no more: one, rather "one".
From the rails console:
>>h = { :one =>1, :two => "two"} {:one=>1, :two=>"two"} >>j = ActiveSupport::JSON.encode(h) "{\"one\":1,\"two\":\"two\"}" >>h2 = ActiveSupport::JSON.decode(j) {"one"=>1, "two"=>"two"} >>h2[:one] nil >>h[:one] 1
Now I switched to using Marshal.dump / load. However, I wanted to drop it there to find out if there is a way to save this in JSON (read-only).
json ruby ruby-on-rails
Mark Nadig Mar 04 '11 at 15:00 2011-03-04 15:00
source share