JSON 有效字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3234150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 17:32:40  来源:igfitidea点击:

JSON Valid Chars

json

提问by syker

Is the presence of a \' within double quotes "invalid" in the context of a JSON response? Is there a definitive JSON spec that could give me an answer?

在 JSON 响应的上下文中,双引号内的 \' 是否“无效”?是否有一个明确的 JSON 规范可以给我一个答案?

回答by Josiah

Check out http://www.json.org/and scroll down to the "String" diagram.

查看http://www.json.org/并向下滚动到“字符串”图。

You can see there how the \ is a "control" character. If you want a literal backslash within your JSON, you'll need to escape it: "\\"is a valid JSON string, for example.

您可以在那里看到 \ 是一个“控制”字符。如果您想在 JSON 中使用文字反斜杠,则需要对其进行转义:"\\"例如,是有效的 JSON 字符串。