EJSONification of objects on method call: Dates are received as strings


I’ve EJSONified a custom data type that contains a Date property. If I hand this object over in a method call, it is transfered from the client to the server with the correct (custom) data type. However, the date property is initialized as a string containing the ISO formatted date information, it is not a Date object. Why is this so? The docs state that EJSON has full support for Date types.


what kind of date format u expect?

and they also state you can set EJSON.addType(name, factory) where factory is function to transform to your type

so you can check customType.toJSONValue() output and set that factory function to revert it


I expected the Date properties to be JavaScript Date objects, not plain strings. And yes, I’ve already implemented the EJSON API, like .addType(), .toJSONValue() etc. The custom object itself is correctly transferred, but not its Date-typed properties.

The same applies to properties which are custom data types themselves. In this case, I did not really expect the EJSON mechanism to do a deep-conversion. But in the case of standard JavaScript data-types like Date(), I expected this. Also, because the docs highlight full support of Dates as a feature.