Loading ...
Sorry, an error occurred while loading the content.

Re: "\/" escape sequence?

Expand Messages
  • Douglas Crockford
    ... / is a valid escape sequence. However, it is not required that / be escaped. You may escape it if you need to. The reason JSON explicitly allows
    Message 1 of 3 , Feb 4, 2006
    • 0 Attachment
      --- In json@yahoogroups.com, Blake Seely <blakeseely@...> wrote:

      > The language description at http://www.crockford.com/JSON/ says that
      > "\/" is a valid escape sequence.

      "\/" is a valid escape sequence. However, it is not required that / be
      escaped. You may escape it if you need to. The reason JSON explicitly
      allows escaping of slash is because HTML does not allow a string in a
      <script> to contain "...</...". JSON allows "...<\/..." which makes
      HTML happy. If you don't need to escape the slash, then don't. It is
      not required.

      > The examples on Yahoo's page here:
      >
      > http://developer.yahoo.net/common/json.html
      >
      > show this as a valid escape sequence as well - and all URLs in their
      > example use go from "http://blahblah.com/blah/blah" to "http:\/\/
      > blahblah.com\/blah\/blah".

      I asked them to correct that a couple of weeks ago. Even worse, there
      is a syntax error in it.

      > However, all the examples at json.org at this url:
      >
      > http://www.crockford.com/JSON/example.html
      >
      > do NOT insert use it - URLS and unix paths all just use a bare '/'
      > character without first escaping it with '\'. And the sample Java
      > code at json.org here:
      >
      > http://www.crockford.com/JSON/java/org/json/JSONTokener.java
      >
      > do NOT scan for or handle this escape.

      Again, that is because it is not required. Escaping a slash or not
      escaping a slash will have the same result.
    • Blake Seely
      Excellent. Thanks for the info Douglas. ... [Non-text portions of this message have been removed]
      Message 2 of 3 , Feb 4, 2006
      • 0 Attachment
        Excellent. Thanks for the info Douglas.

        On Feb 4, 2006, at 2:37 PM, Douglas Crockford wrote:

        > --- In json@yahoogroups.com, Blake Seely <blakeseely@...> wrote:
        >
        > > The language description at http://www.crockford.com/JSON/ says that
        > > "\/" is a valid escape sequence.
        >
        > "\/" is a valid escape sequence. However, it is not required that / be
        > escaped. You may escape it if you need to. The reason JSON explicitly
        > allows escaping of slash is because HTML does not allow a string in a
        > <script> to contain "...</...". JSON allows "...<\/..." which makes
        > HTML happy. If you don't need to escape the slash, then don't. It is
        > not required.


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.