提交 a38e653a 编写于 作者: N Neeraj Singh 提交者: Andrea Campi

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

上级 964033f3
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册