【发布时间】:2014-10-20 19:43:22
【问题描述】:
我有一个哈希:
my_hash = {"bob.johnson@example.com"=>{"first"=>"Bob", "last"=>"Johnson"}, "lisa.dell@example.com"=>{"first"=>"Lisa", "last"=>"Dell"}}
当我尝试用my_hash.to_json 对其进行序列化时,我得到了:
"{\"bob.johnson@example.com\":{\"first\":\"Bob\",\"last\":\"Johnson\"},\"lisa.dell@example.com\":{\"first\":\"Lisa\",\"last\":\"Dell\"}}"
如何在不获取转义字符的情况下将 Hash 转换为 JSON 格式?
【问题讨论】:
标签: ruby-on-rails ruby json serialization hash