Yeah, it looks like prototype and scriptaculous (and possibly some others)
disagree with crockford on what the toJSON() method returns.

Crockford says: Returns a json primitive (string, number, object, or array),
which you would then pass to a separate encoding routine.
Libs say: Returns a json-encoded value.

We'll probably just want to wait until major browser vendors implement
native JSON to decide what's right here.

On Wed, Mar 5, 2008 at 5:58 PM, Paul Lindner <[EMAIL PROTECTED]> wrote:

> THANK YOU!
>
> I was wondering why Scriptaculous was stringifying arrays to strings with
> brackets...
>
>
> On 3/5/08 5:52 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Author: etnu
> > Date: Wed Mar  5 17:52:51 2008
> > New Revision: 634118
> >
> > URL: http://svn.apache.org/viewvc?rev=634118&view=rev
> > Log:
> > Fixed a problem in json.js due to use of toJSON(). While this is a
> useful
> > addition, it's problematic because it conflicts with other common
> javascript
> > libraries.
> > Updated makeClosure to return the return value of the caller
> (SHINDIG-111)
> >
> > Modified:
> >     incubator/shindig/trunk/features/core/json.js
> >     incubator/shindig/trunk/features/core/util.js
> >
> > Modified: incubator/shindig/trunk/features/core/json.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/core/json.js?rev
> > =634118&r1=634117&r2=634118&view=diff
> >
> ==============================================================================
> > --- incubator/shindig/trunk/features/core/json.js (original)
> > +++ incubator/shindig/trunk/features/core/json.js Wed Mar  5 17:52:51
> 2008
> > @@ -109,10 +109,7 @@
> >        if (!value) {
> >          return 'null';
> >        }
> > -    // If the object has a toJSON method, call it, and stringify the
> result.
> > -      if (typeof value.toJSON === 'function') {
> > -        return stringify(value.toJSON());
> > -      }
> > +      // toJSON check removed; re-implement when it doesn't break other
> libs.
> >        a = [];
> >        if (typeof value.length === 'number' &&
> >            !(value.propertyIsEnumerable('length'))) {
> >
> > Modified: incubator/shindig/trunk/features/core/util.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/core/util.js?rev
> > =634118&r1=634117&r2=634118&view=diff
> >
> ==============================================================================
> > --- incubator/shindig/trunk/features/core/util.js (original)
> > +++ incubator/shindig/trunk/features/core/util.js Wed Mar  5 17:52:51
> 2008
> > @@ -151,7 +151,7 @@
> >          for (var i = 0, j = arguments.length; i < j; ++i) {
> >            tmpArgs.push(arguments[i]);
> >          }
> > -        callback.apply(scope, tmpArgs);
> > +        return callback.apply(scope, tmpArgs);
> >        };
> >      },
> >
> >
> >
>
>


-- 
~Kevin

Reply via email to