W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2016

Re: JSON-serializable object

From: Anne van Kesteren <annevk@annevk.nl>
Date: Wed, 16 Nov 2016 15:57:57 +0100
Message-ID: <CADnb78hOfT_3TCDDYjCmVd7DgxHp4MAKAFfnzNOdD5RMVm2p8g@mail.gmail.com>
To: Domenic Denicola <d@domenic.me>
Cc: Marcos Caceres <marcos@marcosc.com>, public-script-coord <public-script-coord@w3.org>
On Wed, Nov 16, 2016 at 3:42 PM, Domenic Denicola <d@domenic.me> wrote:
> A JSON-serializable object is an object on which running JSON.stringify does not throw an error.

That is not quite the same as "an object that can be serialized to a
string using JSON.stringify and later deserialized back to an object
using JSON.parse with no loss of data" though. E.g., you can
JSON.stringify() an object with a prototype, but the object you get
back after these operations does not have that prototype. So there is
a data loss, but it's probably fine?


> As such, ideally all algorithms in the spec should be recast to something like:

Right, that would actually make things clear.


> I think that the only real way that we could improve the situation is to define an abstract operation in ES, e.g. JSONStringify(obj), which takes care of the "as if by..." clause. That's more of a job for ES than it is for IDL.

Yeah, having JSONParse(string) would help some other specifications
(XMLHttpRequest and Fetch come to mind).


-- 
https://annevankesteren.nl/
Received on Wednesday, 16 November 2016 14:58:26 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 16 November 2016 14:58:27 UTC