//JSON.parse方法的使用
//将字符串还原为Date对象
var book={
"title":"professional js",
"authors":["Nicholas C ZAKAS"],
"edition":3,
"year":"2011",
"releaseDate":new Date(2011,11,1)
};
var jsonText=JSON.stringify(book);
var bookCopy=JSON.parse(jsonText,function(key,value){
if(key=="releaseDate"){
return new Date(value);
}else{
return value;
}
});
console.log(bookCopy.releaseDate.getFullYear());