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

json2.js

Expand Messages
  • Douglas Crockford
    I added toJSON methods to Boolean, Number, and String. This makes simple type wrappers work correctly, so JSON.stringify(new String( string )) produce
    Message 1 of 15 , Jul 9 1:10 PM
    • 0 Attachment
      I added toJSON methods to Boolean, Number, and String. This makes
      simple type wrappers work correctly, so

      JSON.stringify(new String('string'))

      produce "string". If you don't use the type wrappers (and it is best
      that you don't) then you can delete those methods.
    • Douglas Crockford
      I modified json2.js slightly to coexist more easily with native JSON libraries. http://www.JSON.org/json2.js
      Message 2 of 15 , Sep 1, 2008
      • 0 Attachment
        I modified json2.js slightly to coexist more easily with native JSON
        libraries.

        http://www.JSON.org/json2.js
      • Lucas Smith
        Doug, Can you elaborate on the changes? Do you maintain the source in a VCS, or is it the responsibility of consumers to store copies locally to see diffs?
        Message 3 of 15 , Sep 1, 2008
        • 0 Attachment
          Doug,

          Can you elaborate on the changes? Do you maintain the source in a
          VCS, or is it the responsibility of consumers to store copies locally
          to see diffs?

          Luke

          On Sep 1, 2008, at 3:03 PM, Douglas Crockford wrote:

          > I modified json2.js slightly to coexist more easily with native JSON
          > libraries.
          >
          > http://www.JSON.org/json2.js
          >
          >
          >



          [Non-text portions of this message have been removed]
        • Douglas Crockford
          ... A JSON object is created if one doesn t exist. If the object does not have a stringify method, one is added. If the object does not have a parse method,
          Message 4 of 15 , Sep 2, 2008
          • 0 Attachment
            --- In json@yahoogroups.com, Lucas Smith <lsmith@...> wrote:
            > Can you elaborate on the changes?

            A JSON object is created if one doesn't exist.

            If the object does not have a stringify method, one is added.

            If the object does not have a parse method, one is added.
          • Douglas Crockford
            I changed the stringify method s array test from if (typeof value.length === number && !value.propertyIsEnumerable( length )) { to the more reliable Miller
            Message 5 of 15 , Nov 19, 2008
            • 0 Attachment
              I changed the stringify method's array test from

              if (typeof value.length === 'number' &&
              !value.propertyIsEnumerable('length')) {

              to the more reliable Miller device

              if (Object.prototype.toString.apply(value) === '[object Array]') {

              See http://blog.360.yahoo.com/douglascrockford?p=916
            • Douglas Crockford
              json2.js is now available on Github. https://github.com/douglascrockford/JSON-js
              Message 6 of 15 , Nov 18, 2010
              • 0 Attachment
                json2.js is now available on Github.

                https://github.com/douglascrockford/JSON-js
              Your message has been successfully submitted and would be delivered to recipients shortly.