我在
PHP中使用json_encode来编码一个URL
$json_string = array ('myUrl'=> 'http://example.com'); echo json_encode ($json_string);
{"myUrl":"http:\/\/example.com"}
而不是
{"myUrl":"http://example.com"}
根据
http://www.json.org/,一个人应该逃避这个角色,虽然JavaScript并不是绝对必要的:
还可以在PHP.net上阅读这个related bug report,进行简短的讨论.
参见RFC中的2.5:
All Unicode characters may be placed
within the quotation marks except for
the characters that must be escaped:
quotation mark,reverse solidus,and
the control characters (U+0000 through
U+001F).Any character may be escaped.
所以它听起来不像是需要被转义,但它可以,网站(和RFC中的一个文本图)说明它被转义.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。