Re: JSON-serializable object

On Wed, Nov 16, 2016 at 3:42 PM, Domenic Denicola <> 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).


Received on Wednesday, 16 November 2016 14:58:26 UTC