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

[whatwg] JSON support for worker postMessage

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 17 Nov 2008 20:03:45 -0800
Message-ID: <49223EA1.4060504@sicking.cc>
Hi All,

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.

Wanted to see what the reactions to this was. Is it a good idea or not?

I seem to recall this coming up in the past in the original feedback 
about what features people wanted.

The technical details are as follows:
Any of the following values are passed by value as-is:
* strings
* numbers
* booleans
* undefined
* null

Anything else is passed to JSON.stringify (defined by Ecmascript drafts 
here[1]). If calling JSON.stringify throws the same error will be thrown 
by the function. Otherwise the message event fired on the other 'side' 
will contain the result of JSON.parse.

/ Jonas
Received on Monday, 17 November 2008 20:03:45 UTC

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