JSON.parse() replacer param.
JSON.stringify(value[, replacer[, space]])
. MDN
, json.
function replacer(key, value) {
return key == "date1" || key == "date2" ? new Date(value) : value;
}
var obj = {
date1:"5/21/2012 4:49:17 PM",
date2:new Date()
}
var jsonString = JSON.stringify(obj);
console.log(jsonString);
var jsonObj = JSON.parse(jsonString, replacer);
console.log(jsonObj);