title: Rendering a hash inside a JSON file with Ruby and ERB ('=>' notation)
body: <p>I am trying to render a JSON template using ERB, unfortunately, due to the '=>' hash notation, it's not as simple as it was using Python.
  Here's a short example:</p>
  
  <pre><code>  require 'erb'
  
    h = Hash.new
    h["first"] = "First"
    h["second"] = "Second"
  
    template = ERB.new &lt;&lt;-EOF
    {
      "key": "value",
      "foo": 1,
      "Hash": &lt;%= h %&gt;,
      "bar": 2
    }
    EOF
  
    puts template.result(binding)
  </code></pre>
  
  <p>This code will produce this output:</p>
  
  <pre><code>  {
      "key": "value",
      "foo": 1,
      "Hash": {"first"=&gt;"First", "second"=&gt;"Second"},
      "bar": 2
    }
  </code></pre>
  
  <p>Converting the '=>' notation to colons will result in a valid json file.
  Is there a way to so using Ruby/ERB that I'm no aware of (except for printing keys, values and characters separately)? Or should run a substitution on my generated json files?</p>
  
  <p>I feel like I'm missing the obvious solution </p>