0
我有一個ruby json對象。例如如何將"轉換爲double qoutes
在控制器
@my_hash = {"5":{"id":5,"name":"ANKLOS","code":"724.9","description":"Ankylosis of spine (Spine Fusion)","title":"ANKLOS - 724.9 - Ankylosis of spine (Spine Fusion)"},"3":{"id":3,"name":"Loren Lipsum","code":"Test","description":"Test t2 stest","title":"Loren Lipsum - Test - Test t2 stest"}}
我用@my_hash在視圖中。我的內容是從表中動態獲得的。
<script type="text/javascript">
var my_hash = <%= @my_hash.to_json %>;
</script>
但my_hash的結果就像
var diagnosisCodes = {"":{"code":"\u0026larr;","description":""},"5":{"id":5,"name":"ANKLOS","code":"724.9","description":"Ankylosis of spine (Spine Fusion)","title":"ANKLOS - 724.9 - Ankylosis of spine (Spine Fusion)"},"3":{"id":3,"name":"Loren Lipsum","code":"Test","description":"Test t2 stest","title":"Loren Lipsum - Test - Test t2 stest"}};
我需要輸出同樣喜歡@my_hash。我怎樣才能做到這一點?