JSON 4 (v52)

Revision 52 of this benchmark created by d3v on


Description

This test benchmarks json4 against other JSON implementations. json4 is only a proof on concept, all mayor browsers support this feature nativ!

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:

  • json4 : Uses a character-based recursive decent parser.
  • [`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.nativeJSON = 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>
<!-- `json-parse-state` (Crockford's state machine parser) -->
<script src="http://rawgithub.com/douglascrockford/JSON-js/master/json_parse_state.js"></script>
<script>
  // `json-parse` is exposed via the `json_parse` function as well.
  this.json_parse_state = this.json_parse;
</script>
<!-- `json-parse` (Crockford's recursive descent parser) -->
<script src="http://rawgithub.com/douglascrockford/JSON-js/master/json_parse.js"></script>
<!-- Mike Samuel's `json-sans-eval` -->
<script src="http://json-sans-eval.googlecode.com/svn/trunk/src/json_sans_eval.js"></script>
<!-- Asen Bozhilov's `evalJSON` -->
<script src="http://rawgithub.com/abozhilov/json/master/src/json.js"></script>
<!-- Stephan Dum's json4 -->
<script src="http://rawgithub.com/chaosClown/json4/master/json4.min.js"></script>
<!-- Restore Native -->
<script>
  this.JSON = this.nativeJSON
</script>

Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
JSON 3: parse
JSON3.parse(value);
ready
JSON 2: parse
JSON2.parse(value);
ready
json-parse-state
json_parse_state(value);
ready
json-parse
json_parse(value);
ready
json-sans-eval
jsonParse(value);
ready
evalJSON
evalJSON(value);
ready
json4
json4(value);
ready
JSON.parse() //native
JSON.parse(value)
ready

Revisions

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