[whatwg] asynchronous JSON.parse

j at mailb.org j at mailb.org
Thu Mar 7 00:06:48 PST 2013


right now JSON.parse blocks the mainloop, this gets more and more of an
issue as JSON documents get bigger and are also used as serialization
format to communicate with web workers.
To handle large JSON Documents there is a need for an async JSON.parse,
something like:

 JSON.parse(data, function(obj) { ... });

or more like FileReader:

 var json = new JSONReader();
 json.addEventListener('load', function(event) {
   //parsed JSON document in: this.result
 });
 json.parse(data);

While my major need is asynchronous parsing of JSON data, the same is
also true for serialization into JSON.

 var json = new JSONWriter();
 json.addEventListener('load', function(event) {
   // serialized JSON string in: this.result
 });
 json.serialize(obj);


More information about the whatwg mailing list