json parse string vs eval (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}';
  var errorMsg = null;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
eval
eval("errorMsg = " + jsontext + ";");
var a = errorMsg.firstname;
ready
json
errorMsg = JSON.parse(jsontext);
var a = errorMsg.firstname;
ready
function constructor
errorMsg = new Function("return " + jsontest)();
var a = errorMsg.firstname;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.