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 beal
http://wanderinghorse.net/home/stephan/

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

Reply via email to