On 2018-03-18 21:06, Mike Samuel wrote:


On Sun, Mar 18, 2018, 4:00 PM Anders Rundgren <[email protected] 
<mailto:[email protected]>> wrote:

    On 2018-03-18 20:23, Mike Samuel wrote:
     >     It is possible that I don't understand what you are asking for here 
since I have no experience with toJSON.
     >
     >     Based on this documentation
     > 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
 
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify>
     >     JSON.canonicalize() would though work out of the box (when 
integrated in the JSON object NB...) since it would inherit all the functionality 
(and 99% of the code) of JSON.stringify()
     >
     >
     > JSON.stringify(new Date()) has specific semantics because 
Date.prototype.toJSON has specific semantics.
     > As currently written, JSON.canonicalize(new Date()) === 
JSON.canonicalize({})

    It seems that you (deliberately?) misunderstand what I'm writing above.

    JSON.canonicalize(new Date()) would do exactly the same thing as 
JSON.stringify(new Date()) since it apparently only returns a string.


Where in the spec do you handle this case?

It doesn't, it only describes a canonicalization algorithm.

Integration of the canonicalization algorithm in the ES JSON object might cost 
as much a 5 lines of code + some refactoring.

Anders


    Again, the sample code I provided is a bare bones solution with the only 
purpose showing the proposed canonicalization algorithm in code as a complement 
to the written specification.


Understood.  AFAICT neither the text nor the instructional code treat Dates 
differently from an empty object.


    Anders


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to