我在Ruby on Rails上工作。我有一个像这样的Json字符串
"{\"user\":{\"email\":\"blah@blah.com\",\"name\":\"blah Test 1051\",\"mobile\":\"9999999999\",\"dob\":\"00/00/0000\",\"street\":\"somewhere\",\"state\":\"something\",\"city\":\"nowhere\",\"pincode\":\"50000\",\"Event_Code\":\"e0031\"}}"
我需要将此转换为JSON哈希,如此
{"user"=>{"email"=>"blah@blah.com", "name"=>"blah Test 1051", "mobile"=>"9999999999","dob"=>"00/00/0000","street"=>"somewhere","state"=>"something","city"=>"nowhere","pincode"=>"50000","Event_Code"=>"e0031"}}
答案 0 :(得分:2)
答案 1 :(得分:0)
JSON.parse "{\"user\":{\"email\":\"blah@blah.com\",\"name\":\"blah Test 1051\",\"mobile\":\"9999999999\",\"dob\":\"00/00/0000\",\"street\":\"somewhere\",\"state\":\"something\",\"city\":\"nowhere\",\"pincode\":\"50000\",\"Event_Code\":\"e0031\"}}"
检查http://apidock.com/ruby/JSON/parse以获取更多参考资料