[whatwg] JSON support for worker postMessage

Ian Hickson ian at hixie.ch
Mon Dec 15 20:51:09 PST 2008

On Mon, 17 Nov 2008, Jonas Sicking wrote:
> Ben just wrote up a patch to support JSON objects as well as primitive 
> values (0, null, false, etc) to be passed to and from workers using 
> postMessage.

Ok well I guess waiting for the rest to be implemented isn't going to work 
if y'all start implementing it on your own. :-)

Added to the spec, though without mentioning JSON, and with requirements 
slightly different than JSON. Specifically:

   - I used NOT_SUPPORTED_ERR instead of a generic Error in the case of
     a cycle being detected.

   - I allowed all Number values (including Infinity and NaN) to pass 
     through unscathed.

   - I didn't stringify host objects, I just converted them to null. This 
     avoids things like people putting DOMStorage objects in there and 
     seeing megabytes of data getting copied unintentionally.

   - I made Array and Object cloning work basically the same, and made 
     them preserve order. In particular, [1,,2] survives intact (unlike 
     in either the JSON.stringify() spec or in implementations).

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list