Great! stringify seems like it would make things even messier, but I guess (though I'd have to look) if JSON is natively supported then the browser vendor also has e.g. Date.prototype.toJSON() defined as well.
I look forward to seeing your code! especially that last case. On Oct 25, 6:13 am, Thomas Broyer <[email protected]> wrote: > On 23 oct, 22:55, Brendan <[email protected]> wrote: > > > I realize this post is coming at the end of the day on friday, but > > hopefully it will get a look =) > > > Going through the different JSON parsing implementations available for > > GWT out there, almost all of them rely on a straight eval and note > > that they should only be used for trusted code. The old JSONValue code > > seems kind of quaint in light of JavaScriptObjects, and looking > > through the trunk it looks like there's just a TODO in JsonUtils for > > safe parsing. > > Funny! I'm finishing a JsonUtils patch (was about to submit it this > night but finally chose to review it one more time, ensuring tests > pass, checkstyle, etc.) adding: > - JsonUtils.safeParse > - JsonUtils.stringify > - JsonUtils.isArray (equivalent of ECMAScript 5's Array.isArray) > - deferred binding implementations using either native support > (user.agent=ie8) or emulation (eval() for the parsing; user.agent= > {ie6,gecko,opera}), and a fallback to emulation when native support > isn't available (e.g. recent versions of Firefox, Chrome and Safari > have native support, but older versions do not, so we detect if native > JSON is supported –recent versions– and fallback to emulation > otherwise –older versions–; user.agent={gecko1_8,safari}) > > I'm using a similar code at work with no problem so far. > > I'll ping when my patch is sent for review. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
