Open hongnk opened 5 years ago
When sending Date objects, they are serialized into ISO string format, and JSON parse doesn't convert them back.
Propose to add option to JSON decode function, for example
const dateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/; function dateReviver(key, value) { if (typeof value === "string" && dateFormat.test(value)) { return new Date(value); } return value; } module.exports.decode = function(str) { return JSON.parse(str, dateReviver) }
How about adding EJSON support?
When sending Date objects, they are serialized into ISO string format, and JSON parse doesn't convert them back.
Propose to add option to JSON decode function, for example