All JSON.parse
implementations most likely use eval()
JSON.parse
is based on Douglas Crockford's solution, which uses eval()
right there on line 497.
// 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 + ')');
The advantage of JSON.parse
is that it verifies the argument is correct JSON syntax.