I've tried everything. Every combination of the helpers
var campaignData<%= "=" + (raw @campaign.to_json) if @campaign %>;
The problem here is with the "=" string. As it's considered unsafe, it taints the other string.
You can probably do either:
raw("=" + @campaign.to_json)
which are roughly the same.