Re: [heycam/webidl] Replace serializers by toJSON and [Default] extended attribute (#323)

tobie commented on this pull request.



> @@ -1985,6 +1989,122 @@ The following extended attributes are applicable to operation arguments:
         "void"
 </pre>
 
+<h5 id="idl-tojson-operation">toJSON</h5>
+
+By declaring a “toJSON” [=regular operation=],
+an [=interface=] specify how to convert the objects that implements it to [=JSON values=].
+
+The “toJSON” [=regular operation=] is reserved for this usage.
+It must take zero arguments and return a [=JSON value=].
+
+The list of <dfn id="dfn-json-values" export lt="JSON value">JSON values</dfn> is as follows:

So this is named after ECMA-404 which distinguishes between JSON text and JSON values (with the former being the stringified version of the latter). Deep-linking to ECMA-404 isn't possible, since the spec is a pdf, so I didn't.

I also considered calling this a type, but then I wasn't sure if we could define a type in prose which had restrictions the way this one does.

I'll go with whatever you suggest here.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/323#discussion_r103534118

Received on Tuesday, 28 February 2017 19:34:25 UTC