Re: parseLenient and parseStrict on newer browsers [was Re: seemingly misleading verbiage in the documentation...]

2011-04-01 Thread Thomas Broyer
If you know that your JSON is "wellformed JSON" (and not just the more 
liberal JavaScript's literal object notation), then use parseStrict.
Only use parseLenient if you know your "JSON" isn't actually JSON (i.e. from 
a "legacy" server).
That should be the rule IMO, independently from performance.

It also turns out this is the fastest, except in IE6/IE7 and "older Safari" 
(JSON.parse was added in Safari 4.0.3 IIRC; I don't know for Mobile Safari 
but I guess there are still some iPhones out there without JSON.parse 
support). Most other "older browsers" without JSON.parse are probably gone 
from the Internet now (Firefox 3.0, Opera 9)

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



parseLenient and parseStrict on newer browsers [was Re: seemingly misleading verbiage in the documentation...]

2011-03-31 Thread karthik reddy
"parseLenient *only* uses eval(), not only as a 
fallback.  ."

I went into the source code and took a look at the parseLenient method. You 
are correct. parseLenient always uses eval().   The following is the code 
snippet that  confirmed this fact for me: 

" 
 
@com.google.gwt.core.client.JsonUtils::escapeJsonForEval(Ljava/lang/String;)(json)".
 

Thanks for correcting my premise.

Now, the natural question that popped in my mind is:

Lets say there is a scenario where* the JSON to be parsed is totally trusted
* .  In such a case ,   I am trying to find out how parseLenient compares 
with parseStrict( *in terms of raw speed*) for new browsers that have native 
JSON support(IE8+, FF4 etc)

Going by the following posts by Mozilla and Microsoft, it seems like native 
JSON would be the way to go because they claim that the native JSON is much 
faster and it sounds like it is only gonna improve over time:

http://blog.mozilla.com/webdev/2009/02/12/native-json-in-firefox-31/

http://blogs.msdn.com/b/ie/archive/2008/09/10/native-json-in-ie8.aspx


Any thoughts are much appreciated.

thanks
 

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