Fake JSON parse (v2)

Revision 2 of this benchmark created by Fabio Crisci on


Description

Test the creation of a JS Object from a "fake" json, it's not actually JSON but the JS Object notation

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var small = '{some : 12, thing: "goes", here : ["one ", "two ", "three "]}';
  
  var big = '{bigger:{object:{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12},repeat:[{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12},{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12},{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12},{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12},{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12},{can:["contain ","several ","other ",{obje:"cts "}],just:{check:["that ","both ",{the:"methods "},"works ",{even:{when:{there:"are "},big:"objects "}}]},number:12}]}}';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Small - Eval
json = eval('(' + small + ')');
ready
Small - Function
json = (new Function("return " + small))();
ready
Big - Eval
json = eval('(' + big + ')');
ready
Big - Function
json = (new Function("return " + big))();
ready

Revisions

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

  • Revision 1: published by Fabio Crisci on
  • Revision 2: published by Fabio Crisci on