If you really want to use JSON.stringify, just do:

if (!JSON.stringify) JSON.stringify = JSON.encode;
if (!JSON.parse) JSON.stringify = JSON.decode;

Furthermore I agree with Christoph.

On Wed, Feb 16, 2011 at 11:51 PM, Garret Wilson <[email protected]>wrote:

> On Feb 16, 7:57 am, Christoph Pojer <[email protected]> wrote:
>
> > JSON.parse and JSON.stringify are indeed standards of ECMAScript 5.
> However,
> > they both provide additional arguments which we do not want to support.
>
> So we could throw an exception of one of these additional arguments
> are passed in. What is important to me is that:
>
> 1. I use standard method calls.
> 2. My code uses native logic when available.
> 3. My code doesn't die when native logic is not available.
>
> With proprietary MooTools methods, our use of JSON functionality is
> limited in relation to ECMAScript 5. If on the other hand MooTools
> were to use the same method names but throw exceptions for unsupported
> functionality, JSON functionality would not be any less than the first
> option---but we would be using standard method names, which is very
> important to me.
>
> Garret

Reply via email to