Why Angular2 override JSON.stringify !?
I have override my own Date.toJSON but it's not called when stringify an object.
In the following exemple it's work correctly, but it doesn't work in Angular App !
<html>
<body>
Custom Date Fomat : <span id="date1"></span><br>
ISO Date Format : <span id="date2"></span>
</body>
<script>
Date.prototype.toJSON = function(){
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var s = year + "-" +
(month > 9 ? "" : "0") + month + "-" +
(day > 9 ? "" : "0") + day + "T00:00:00.000Z";
return s;
}
var date = new Date();
document.getElementById("date1").innerHTML = JSON.stringify({date});
document.getElementById("date2").innerHTML = date.toISOString();
</script>
</html>