Consider the following two scenarios:
Ruby 1.8.7 Rails 2.3.2
{:a => '<div style="color:red;">asd</div>'}.to_json
?> {"a":"\u003div style=\"color:red;\"\u003Easd\u003/div\u003E"}
this does not cause any problems when i do jQuery.parseJSON()
Ruby 1.8.7 Rails 3.0.9
{:a => '<div style="color:red;">asd</div>'}.to_json
?> {"a":"<div style=\"color:red;\">asd</div>"}
this causes error - JSON.parse: expected ',' or '}' after property value in object when i do jQuery.parseJSON()
Have tried the following:
- ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', self + ' ')[0..-2]
- .html safe
- JSON.encode
None are working. This is really killing me!
Thanks in advance.
Update : The json renderer
render :text => {:success => true, :replacement => '<div style="color:red;">asd</div>'}.to_json
also tried
render :json => {:success => true, :replacement => '<div style="color:red;">asd</div>'}