Created
January 18, 2010 12:15
-
-
Save fjakobs/279965 to your computer and use it in GitHub Desktop.
Date serializer [qx]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = { date: new Date(123)} | |
Date.prototype.toJSON = function() { | |
return { $$date$$: this.getTime() } | |
} | |
var json = qx.lang.Json.stringify(obj); | |
console.log(json) | |
var obj = qx.lang.Json.parse(json, function(k, v) { | |
if (v.$$date$$) { | |
return new Date(v.$$date$$) | |
} else { | |
return v; | |
} | |
}) | |
console.log(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment