JSON decoding

Brendan Eich brendan at mozilla.org
Fri Oct 20 12:42:23 PDT 2006


On Oct 20, 2006, at 3:36 PM, Erik Arvidsson wrote:

> If Date is serialized as an ISO strings the process of encoding and
> decoding loses information. If Dates are added to JSON then they
> should be encoded using new Date(ms). However Dates are not supported
> in JSON today and removing them from JS2 seems OK.

ES4 also standardizes Date.parse to accept the same ISO 8601 date  
strings, so I don't believe any information is lost.

You're right that this automatic encoding of Date objects as ISO  
strings does not result, when decoding, in Date objects again.   
Fixing that would require a pass over the decoded structure, or a use  
of the optional object hook on the enclosing object.  Is this a problem?

/be



More information about the Es4-discuss mailing list