

def extract_dates(obj):
    'extract ISO8601 dates from unpacked JSON'
    if isinstance(obj, dict):
        obj = dict(obj)
        for (k, v) in obj.items():
            obj[k] = extract_dates(v)
    elif isinstance(obj, (list, tuple)):
        obj = [extract_dates(o) for o in obj]
    elif isinstance(obj, str):
        if ISO8601_PAT.match(obj):
            obj = datetime.strptime(obj, ISO8601)
    return obj

dataset/ETHPy150Open ipython/ipython-py3k/IPython/utils/jsonutil.py extract_dates/original