Maybe the built-in JSON object in V8 is not the same as crocker's
implementation?

On Dec 8, 5:45 am, Stephan Beal <[email protected]> wrote:
> On Thu, Dec 8, 2011 at 2:35 PM, Rico Wind <[email protected]> wrote:
> > Try to use JSON.parse instead of eval
>
> Crockford's impl of JSON.parse() simply verifies the data intensively
> before running eval() on it to do the real parsing. i.e. in that particular
> implementation calling JSON.parse() cannot possibly be faster than simply
> using eval.
>
> https://github.com/douglascrockford/JSON-js/blob/master/json2.js
>
> // In the third stage we use the eval function to compile the text into a
> // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
> // in JavaScript: it can begin a block or an object literal. We wrap the text
> // in parens to eliminate the ambiguity.
>
>                 j = eval('(' + text + ')');
>
> --
> ----- stephan bealhttp://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to