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

JSON Compatibility Issues

Expand Messages
  • Kazuho Oku
    Subject: JSON Compatibility Issues Hi, While I was debugging my web application, I found following compatibility issues regarding JSON and major web browsers.
    Message 1 of 1 , Dec 18, 2006
    • 0 Attachment
      Subject: JSON Compatibility Issues

      Hi,

      While I was debugging my web application, I found following
      compatibility issues regarding JSON and major web browsers.


      1) ECMAScript conformance of RFC 4627 (JSON RFC)

      According to Section 7.3 and 7.8.4 of ECMA-262 3rd Edition, U+2028 nor
      U+2029 are permitted within string literals, but RFC 4627 does not
      state as such in Section 2.5. I think this issue should be fixed so
      that JSON would be compatible with ECMAScript.


      2) Browser implementation issues regarding string literals

      Most web browsers seem to require yet more characters to be escaped
      within string literals.

      According to my test, IE 6 and 7, and Safari 2.0.4 fails to parse NUL
      characters (without being escaped) within string literals. Firefox
      1.5 and 2.0 silently drops following characters within string literals
      if not escaped: U+200C-U+200F, U+202A-U+202E, U+206A-U+206F, U+FEFF.
      Opera 9 seems to be the only browser comformant to the ECMA
      specification. Test code is attached below.

      Although this is not a problem of the JSON specification, I think it
      would be helpful for developers if the specification recommended using
      escape sequences for the above characters as well.

      Thank you.



      // test code for finding characters that should be escaped
      var a = [];
      for (var i = 0; i < 65536; i++) {
      var s = '';
      try {
      eval('s = "' + String.fromCharCode(i) + '"');
      } catch (e) {
      }
      if (s.length != 1) {
      a.push(i.toString(16));
      }
      }
      alert(a.join(' '));
    Your message has been successfully submitted and would be delivered to recipients shortly.