Check if json functions are already there, if they're not there then load up
json2.js with $.getScript

On Tue, Aug 18, 2009 at 09:22, Mark Gibson <jollyt...@gmail.com> wrote:

>
> On second thoughts John, i have to agree with you, especially as it
> can be implemented using a filter...
>
> function myfilter( type, data ) {
>    return type === 'json' ? JSON.parse(data, reviver) : data;
> }
>
> at least this would error if JSON didn't exist, and not silently
> produce different results.
>
> Regards
> - Mark
>
> 2009/8/18 John Resig <jere...@gmail.com>:
> > "that old piece of missing functionality"? Being what? Wholesale
> importing
> > json2.js? That doesn't seem practical - especially since if json2.js is
> > already included in a page (or if the native JSON object exists) we use
> it.
> >
> > --John
> >
> >
> > On Mon, Aug 17, 2009 at 12:14 PM, Daniel Friesen <
> nadir.seen.f...@gmail.com>
> > wrote:
> >>
> >> IIRC json2 supports it... We could get around to fixing that old piece
> >> of missing functionality in jQuery and kill two birds with one stone.
> >>
> >> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
> >>
> >> John Resig wrote:
> >> > I'd be wary of adding that - especially since it wouldn't work for
> >> > browsers that don't support JSON.parse.
> >> >
> >> > --John
> >> >
> >> >
> >> > On Mon, Aug 17, 2009 at 3:12 AM, Mark Gibson <jollyt...@gmail.com
> >> > <mailto:jollyt...@gmail.com>> wrote:
> >> >
> >> >
> >> >     Hi, any chance we could add a reviver option to the ajax settings
> >> > for
> >> >     JSON requests?
> >> >     This could also be used by other plugins that parse JSON data too.
> >> >
> >> >     - Mark
> >> >
> >> >     Index: src/ajax.js
> >> >
> ===================================================================
> >> >     --- src/ajax.js (revision 6529)
> >> >     +++ src/ajax.js (working copy)
> >> >     @@ -182,7 +182,8 @@
> >> >                            json: "application/json, text/javascript",
> >> >                            text: "text/plain",
> >> >                            _default: "*/*"
> >> >     -               }
> >> >     +               },
> >> >     +               jsonReviver: null
> >> >            },
> >> >
> >> >            // Last-Modified header cache for next request
> >> >     @@ -565,7 +566,7 @@
> >> >                            // Get the JavaScript object, if JSON is
> >> > used.
> >> >                            if ( type === "json" ) {
> >> >                                    if ( typeof JSON === "object" &&
> >> >     JSON.parse ) {
> >> >     -                                       data = JSON.parse( data );
> >> >     +                                       data = JSON.parse( data,
> >> >     s.jsonReviver );
> >> >                                    } else {
> >> >                                            data = (new
> >> >     Function("return " + data))();
> >> >                                    }
> >> >
> >> >
> >> >
> >> >
> >> > >
> >>
> >>
> >
> >
> > >
> >
>
> >
>


-- 
Samer Ziadeh
www.samerziadeh.com


"Let It Be"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to