That too is one of the many things that has bothered me. At work we 
actually use a wrapper function which will try to make use of any one of 
the existing json libraries on json.org, or native JSON if available, 
basically if it can find a JSON parser loaded into the page it'll try to 
use it instead of eval.

I was hoping to get an actual website up and clearly explain 4query's 
purpose before I mentioned it.
But I should note that I actually patched support for that kind of thing 
downstream:
http://github.com/dantman/4query/commit/bb5ea3b4b128f851871b433d826f3c76f7644086

Oh, though now that I think about it, I should probably patch in a 
try/catch as well since one or two of the libs throw syntax errors as a 
singal when JSON is malformed.
I'm also considering whether I should rename the method or not.

try/catch is in 
http://github.com/dantman/4query/commit/f8e62c0c2f0c2e19d5294c67ce2df6052fa2d6a9

Same license as jQuery so if jQuery wants any 4query improvements it's 
fine to incorporate.

Just a small note on why I used $.json instead of $.support; $.support 
is checked fairly early on, but like at work I wanted full support for 
however the json libraries are loaded. If $.support was used then 
various methods of deferring the library load might end up with the 
library not being used. I don't know how late .support is run, but 
depending on when it's run; a <script> included after the framework 
might not work, deferring the json library by putting it at the bottom 
of the body might not work. At the very least loading a json library in 
the .ready event or after is unlikely to be caught by $.support (In case 
you wanted to completely defer json library loading till you knew you 
actually needed to parse some json).

~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://nadir-seen-fire.com]
-Nadir-Point (http://nadir-point.com)
-Wiki-Tools (http://wiki-tools.com)
-MonkeyScript (http://monkeyscript.nadir-point.com)
-Animepedia (http://anime.wikia.com)
-Narutopedia (http://naruto.wikia.com)
-Soul Eater Wiki (http://souleater.wikia.com)

ajpiano wrote:
> With the advent of native JSON support in browsers forthcoming, should
> jQuery.support check for the existence of the JSON obj and use it as
> the preferred way of parsing JSON whenever the library needs to do
> so?  This would have the added benefit of leveraging json2.js for
> users who already have that library in use on sites with jQuery.
>
> --adam
> >
>   

--~--~---------~--~----~------------~-------~--~----~
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