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
Can't you have a look at the javadoc and the source code?
See
http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/json/client/JSONParser.html
(in other words, the doc is outdated)
--
You received this message because you are subscribed to the Google Groups
Google Web
Any thoughts on this would be much appreciated. I am trying to validate my
understanding of JSONParser class and also highlight the misleading verbiage
in the documentation.
--
You received this message because you are subscribed to the Google Groups
Google Web Toolkit group.
To post to this
Thanks Thomas.
In fact, I did look at the javadoc, and even the javadoc has kinda ambiguous
verbiage . More precisely, parseStrict's description is right on :
Evaluates a JSON string and returns its JSONValue representation. Where
possible, the browser's JSON.parse function is used. For older
parseLenient *only* uses eval(), not only as a fallback. This is because
JSON is stricter than JavaScript's object literal notatio: in JSON, object
property names must be quoted; JS can include comments, etc. JSON.parse
cannot parse those JS literal objects that do not quote property names
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: