Created
April 27, 2012 00:11
-
-
Save mikeal/2504336 to your computer and use it in GitHub Desktop.
Date parsing JSON
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
JSON._dateReviver = function (k,v) { | |
if (v.length !== 24 || typeof v !== 'string') return v | |
try {return new Date(v)} | |
catch(e) {return v} | |
} | |
JSON.parseWithDates = function (obj) { | |
return JSON.parse(obj, JSON._dateReviver); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about dateify? I've always thought stringify was weird so why not keep up the tradition?