title: Rails hash of hashes in Javascript
body: <p>i have a hash of hashes in rails, like :</p>
  
  <pre><code>{"round"=&gt;1, "turn"=&gt;1, "attacker_hp"=&gt;11220, "defender_hp"=&gt;205, "damage"=&gt;95, "attacker"=&gt;#&lt;User id: 2, email:...&gt;}, {"round"=&gt;1, "turn"=&gt;2, "attacker_hp"=&gt;11220, "defender_hp"=&gt;205, "damage"=&gt;95, "attacker"=&gt;#&lt;User id: 1, email:...&gt;} ...
  </code></pre>
  
  <p>So, as you can see, in this hash, there is a number of hashes that represent a combat turn. There is also a hash entry that contains a full object.attributes in it (the 'attacker' entry').</p>
  
  <p>Now, i want to represent that using JQuery in Rails. I've tried to use something like :</p>
  
  <pre><code>var combat_stats = &lt;%= array_or_string_for_javascript(@combat) %&gt;;
  </code></pre>
  
  <p>to get the values in Javascript. This works, but there is an important problem. It seems that it creates an array of strings. Thus, the internal hashes are now strings, which makes it impossible for me to parse in javascript.</p>
  
  <p>My question is, how can i access values like :</p>
  
  <pre><code>turn['attacker']['name'] or turn['attacker_hp']
  </code></pre>
  
  <p>as i could easily do in a @combat.each loop inside Rails view ?</p>