W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2008

[whatwg] JSON support for worker postMessage

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 16 Dec 2008 04:51:09 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0812160141070.30225@hixie.dreamhostps.com>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 15 December 2008 20:51:09 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:08 UTC