JSON doesn't require you to do that, it allows you to do that. It also allows you to use "\u0061" for "A", but it's not required. Allowing \/ helps when embedding JSON in a <script> tag, which doesn't allow </ inside strings, like Seb points out.
Some of Microsoft's ASP.NET Ajax/JSON API's use this loophole to add extra information, e.g., a datetime will be sent as "\/Date(milliseconds)\/". (Yuck)
本文探讨了JSON的灵活性,特别是如何允许使用特殊字符如u0061代替普通字符,并解释了这种灵活性在将JSON嵌入<script>标签时的优势。文章还介绍了微软ASP.NET JSON API如何利用这一特性来增加额外信息,例如通过/Date(milliseconds)/发送日期时间。
1539

被折叠的 条评论
为什么被折叠?



