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

Re: [json] JSON2 is futuristic code? & change request for Date handling

Expand Messages
  • Martin Cooper
    On Mon, May 19, 2008 at 10:56 AM, Peter Michaux wrote: ... So do I. I thought this was one of the big steps forward in moving
    Message 1 of 7 , May 20 1:50 PM
    • 0 Attachment
      On Mon, May 19, 2008 at 10:56 AM, Peter Michaux <petermichaux@...>
      wrote:
      <snip/>

      >
      > This file modifies the built in Data.prototype object. I believe that
      > is the only built-in object it modifies. In many circles modifying
      > objects you don't own is considered a sin. I agree with that
      > sentiment.


      So do I. I thought this was one of the big steps forward in moving from the
      original json.js to the new and improved json2.js, where the former
      augmented several basic types and the latter avoided such augmentation
      altogether.

      http://www.json.org/json.js
      http://www.json.org/json2.js

      It seems like a step backward to regress to the point at which the newer
      code is augmenting basic types again.

      --
      Martin Cooper



      > Would it be acceptable to stop making this augmentation in
      > the json2.js file? I don't think it would change how the file works
      > much and would make the code acceptable to a wider audience. An if
      > statement in the "case: 'object'" section would work, I believe.
      >
      > ----------------
      >
      > There is a comment
      >
      > // Return the JSON object containing the stringify, parse, and quote
      > methods.
      >
      > It doesn't look like a "quote" method is a property of the JSON object.
      >
      > Thanks,
      > Peter
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Mark Joseph
      Is there some place where JSON2 is defined without an implementation (just like version 1.0). Thanks, Mark P6R, Inc On Tue, 20 May 2008 13:50:31 -0700 ... Mark
      Message 2 of 7 , May 20 4:53 PM
      • 0 Attachment
        Is there some place where JSON2 is defined without an
        implementation (just like version 1.0).

        Thanks,
        Mark
        P6R, Inc


        On Tue, 20 May 2008 13:50:31 -0700
        "Martin Cooper" <mfncooper@...> wrote:
        > On Mon, May 19, 2008 at 10:56 AM, Peter Michaux
        ><petermichaux@...>
        > wrote:
        > <snip/>
        >
        >>
        >> This file modifies the built in Data.prototype object. I
        >>believe that
        >> is the only built-in object it modifies. In many circles
        >>modifying
        >> objects you don't own is considered a sin. I agree with
        >>that
        >> sentiment.
        >
        >
        > So do I. I thought this was one of the big steps forward
        >in moving from the
        > original json.js to the new and improved json2.js, where
        >the former
        > augmented several basic types and the latter avoided
        >such augmentation
        > altogether.
        >
        > http://www.json.org/json.js
        > http://www.json.org/json2.js
        >
        > It seems like a step backward to regress to the point at
        >which the newer
        > code is augmenting basic types again.
        >
        > --
        > Martin Cooper
        >
        >
        >
        >> Would it be acceptable to stop making this augmentation
        >>in
        >> the json2.js file? I don't think it would change how the
        >>file works
        >> much and would make the code acceptable to a wider
        >>audience. An if
        >> statement in the "case: 'object'" section would work, I
        >>believe.
        >>
        >> ----------------
        >>
        >> There is a comment
        >>
        >> // Return the JSON object containing the stringify,
        >>parse, and quote
        >> methods.
        >>
        >> It doesn't look like a "quote" method is a property of
        >>the JSON object.
        >>
        >> Thanks,
        >> Peter
        >>
        >> ------------------------------------
        >>
        >> Yahoo! Groups Links
        >>
        >>
        >>
        >>
        >
        >
        > [Non-text portions of this message have been removed]
        >

        -------------------------
        Mark Joseph, Ph.D.
        President and Secretary
        P6R, Inc.
        http://www.p6r.com
        408-205-0361
        Fax: 831-476-7490
        Skype: markjoseph_sc
        IM: (Yahoo) mjoseph8888
        (AIM) mjoseph8888
      • Peter Michaux
        On Tue, May 20, 2008 at 12:31 PM, Douglas Crockford ... I think it would be difficult to argue that the language is broken in this case. It simply does not
        Message 3 of 7 , May 22 11:54 AM
        • 0 Attachment
          On Tue, May 20, 2008 at 12:31 PM, Douglas Crockford
          <douglas@...> wrote:
          > --- In json@yahoogroups.com, "Peter Michaux" <petermichaux@...> wrote:
          >> This file modifies the built in Data.prototype object. In many
          >
          > circles modifying
          >> objects you don't own is considered a sin. I agree with that
          >> sentiment.
          >
          > I don't. Augmentation of the core objects is one of the places where
          > we can effectively repair the language.

          I think it would be difficult to argue that the language is broken in
          this case. It simply does not have a particular method.

          Peter
        • Peter Michaux
          On Tue, May 20, 2008 at 12:31 PM, Douglas Crockford ... There is another weakness in the API caused by the json2.js library s dependency on augmenting
          Message 4 of 7 , Jul 28, 2008
          • 0 Attachment
            On Tue, May 20, 2008 at 12:31 PM, Douglas Crockford
            <douglas@...> wrote:
            > --- In json@yahoogroups.com, "Peter Michaux" <petermichaux@...> wrote:
            >> This file modifies the built in Data.prototype object. In many
            >
            > circles modifying
            >> objects you don't own is considered a sin. I agree with that
            >> sentiment.
            >
            > I don't. Augmentation of the core objects is one of the places where
            > we can effectively repair the language. It should not be done
            > carelessly. I think this is a good use. It will likely be built into
            > the next edition of the standard.

            There is another weakness in the API caused by the json2.js library's
            dependency on augmenting Date.prototype with the toJSON property. If
            the json2.js library is defined in one window and a child window's
            Date object is being stringified, then the child window's
            Date.prototype will not have the toJSON property.

            // parent -----------------------------------------

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
            <html>
            <head>
            <title>Date prototype augmentation test with frames</title>
            <script type="text/javascript">
            Date.prototype.foo = function() {}
            var test = function() {
            var d = window.frames.childFrame.getDate()
            alert(d.foo); // undefined
            }
            </script>
            </head>
            <body>
            <p>parent</p>
            <p><a href="#" onclick="test();return false;">test</a></p>
            <iframe name="childFrame" src="child.html"></iframe>
            </body>
            </html>


            // child --------------------------------

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
            <html>
            <head>
            <title>Page Title</title>
            <script type="text/javascript">
            var getDate = function() {
            return new Date();
            };
            </script>
            </head>
            <body>
            <p>inset</p>
            </body>
            </html>


            Peter
          Your message has been successfully submitted and would be delivered to recipients shortly.