Permalink
Browse files

json_escape makes json invalid doc change [#1485 state:resolved]

  • Loading branch information...
1 parent 0d055de commit 54828a17034d6ffd3a5b203d1b4233c18e818030 Neeraj Singh committed with fxn Apr 28, 2010
Showing with 6 additions and 0 deletions.
  1. +6 −0 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -35,10 +35,16 @@ def html_escape(s)
# A utility method for escaping HTML entities in JSON strings.
# This method is also aliased as <tt>j</tt>.
#
+ # Note that after this operation is performed the output is not
+ # a valid JSON.
+ #
# In your ERb templates, use this method to escape any HTML entities:
# <%=j @person.to_json %>
#
# ==== Example:
+ # puts json_escape("{\"name\":\"john\",\"created_at\":\"2010-04-28T01:39:31Z\",\"id\":1}")
+ # # => {name:john,created_at:2010-04-28T01:39:31Z,id:1}
+ #
# puts json_escape("is a > 0 & a < 10?")
# # => is a \u003E 0 \u0026 a \u003C 10?
def json_escape(s)

0 comments on commit 54828a1

Please sign in to comment.