def extract_dates(obj):
if isinstance(obj, dict):<EOL><INDENT>obj = dict(obj) <EOL>for k,v in obj.iteritems():<EOL><INDENT>obj[k] = extract_dates(v)<EOL><DEDENT><DEDENT>elif isinstance(obj, (list, tuple)):<EOL><INDENT>obj = [ extract_dates(o) for o in obj ]<EOL><DEDENT>elif isinstance(obj, basestring):<EOL><INDENT>if ISO8601_PAT.match(obj):<EOL><INDENT>obj = datetime.strptime(obj, ISO8601)<EOL><DEDENT><DEDENT>return obj<EOL>
extract ISO8601 dates from unpacked JSON