我在哪里可以找到我的JSON的ajax返回类型所需的转义字符列表? [英] Where can I find a list of escape characters required for my JSON ajax return type?

查看:181
本文介绍了我在哪里可以找到我的JSON的ajax返回类型所需的转义字符列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是返回一个JSON对象的ASP.NET MVC的行动。

I have an ASP.NET MVC action that is returning a JSON object.

该JSON:

{status: "1", message:"", output:"<div class="c1"><div class="c2">User generated text, so can be anything</div></div>"}

目前我的HTML是打破它。将有输出字段用户生成的文本,所以我要确保我逃脱需要转义所有的东西。

Currently my HTML is breaking it. There will be user generated text in the output field, so I have to make sure I escape ALL things that need to be escaped.

是否有人有我需要逃避?所有的事情的清单

Does someone have a list of all things I need to escape for?

我不使用任何JSON库,只是建立字符串自己。

I'm not using any JSON libraries, just building the string myself.

推荐答案

看看 http://json.org/ 。它声称比克里斯提出的转义字符的有点不同列表。

Take a look at http://json.org/. It claims a bit different list of escaped characters than Chris proposed.

\"
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits

这篇关于我在哪里可以找到我的JSON的ajax返回类型所需的转义字符列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆