Skip to content

Instantly share code, notes, and snippets.

@fjakobs
Created January 18, 2010 12:15
Show Gist options
  • Save fjakobs/279965 to your computer and use it in GitHub Desktop.
Save fjakobs/279965 to your computer and use it in GitHub Desktop.
Date serializer [qx]
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