Created
April 10, 2011 09:53
-
-
Save stagas/912197 to your computer and use it in GitHub Desktop.
overwrite JSON.parse to deserialize dates
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
;(function() { | |
var parse = JSON.parse | |
JSON.parse = function(s, f) { | |
var ISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/ | |
return parse(s, f ? f : function(key, value) { | |
return typeof value === 'string' | |
? ISO.exec(value) && new Date(value) || value | |
: value | |
}) | |
} | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment