title: Print valid, non-escaped JSON in a view with Rails
body: <p>I've tried everything.  Every combination of the helpers <code>raw</code>, <code>html_safe</code> <code>to_json</code> including some attempts with <code>::JSON.encode</code> and <code>CGI.unescape</code>.  The issue is that regardless of what I  do, I can't print well-formed JSON in a view.  It's always HTML escaped.</p>
  
  <p>Here's the code in my view:</p>
  
  <p><code>var campaignData&lt;%= "=" + (raw @campaign.to_json) if @campaign %&gt;;</code></p>
  
  <p>In my case, it's always the quotes that are escaped as &quot;.  I would just do a gsub on the quotes, but that is a terrible solution to what IMO ought to be a very simple, well documented use case.</p>