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

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

问题描述

我有一个返回 JSON 对象的 ASP.NET MVC 操作.

JSON:

{status: "1", message:"", output:"<div class="c1"><div class="c2">用户生成的文本,所以可以是任何内容</div>

"}

目前我的 HTML 正在破坏它.输出字段中将有用户生成的文本,因此我必须确保转义所有需要转义的内容.

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

我没有使用任何 JSON 库,只是自己构建字符串.

解决方案

看一看 http://json.org/.它声称的转义字符列表与 Chris 提议的略有不同.

<代码>"\/F

	u 四位十六进制数字

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

The JSON:

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

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?

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

解决方案

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

"
\
/

f



	
u four-hex-digits

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

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