JSON 3 (v80)

Revision 80 of this benchmark created on


Description

This test benchmarks JSON 3 against other JSON implementations.

The following implementations support parsing and serializing:

  • JSON 3: Uses a modified, character-based recursive descent parser.
  • JSON 2: Uses eval and a series of validation RegExps.

The following implementations only support parsing:

  • json-parse: Uses a character-based recursive descent parser.
  • json-parse-state: Uses a state machine parser.
  • json-sans-eval: Uses a non-validating RegExp.
  • evalJSON: Uses a RegExp-based recursive descent parser.

Preparation HTML

<!-- JSON 3 v3.2.2 -->
<script>
  // Disable the native JSON implementation.
  this.JSONNative = this.JSON;
  this.JSON = null;
</script>
<script src="http://bestiejs.github.com/json3/lib/json3.min.js"></script>
<!-- JSON 2 -->
<script>
  // Set up JSON 2.
  this.JSON3 = this.JSON;
  this.JSON = null;
</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
<script>
  this.JSON2 = this.JSON;
  this.JSON = null;
</script>
<script src="https://dl.dropboxusercontent.com/u/4374976/JSON4.js"></script>
<script>
  this.JSON4 = this.JSON;
  this.JSON = null;
</script>

Setup

var value = {"kitcambridge":"Kit","contributors":{"jdalton":"John-David","mathias":"Mathias"},"list":[1,2,3],"number":5,"date":"2012-04-25T14:08:36.879Z","boolean":true,"nil":null, array: [[[[1, 2], 3, 4], 5, 6], 7, 8]};

Test runner

Ready to run.

Testing in
TestOps/sec
JSON 3
JSON3.stringify(value, null, 4);
ready
JSON 2: parse
JSON2.stringify(value, null, 4);
ready
test
JSONNative.stringify(value, null, 4);
ready
JSON 4
JSON4.stringify(value, null, 4);
ready

Revisions

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