This is Rails html-encoding your string as is default in Rails 3.
You need to mark your JSON as html_safe
:
var stuff = <%= @json.to_s.html_safe %>
Note that .to_s
is needed because as_json
gives Hash instead of string. You could do this instead:
# in controller
@json = @nodes.to_json(:only => [:ID, :Lat, :Lon])
#and in view
var stuff = <%= @json.html_safe %>