add type json
This commit is contained in:
parent
5919345d3d
commit
e1657994ca
1 changed files with 5 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import re
|
||||
import json
|
||||
from multiprocessing.pool import ThreadPool
|
||||
|
||||
from six import string_types
|
||||
|
@ -77,6 +78,10 @@ class SiteParser(dict):
|
|||
elif self.regex[key]['type'] == 'date':
|
||||
parse_date = lambda d: d and datetime.strptime('-'.join(d), '%m-%d-%Y').strftime('%Y-%m-%d')
|
||||
data = apply_f(parse_date, data)
|
||||
elif self.regex[key]['type'] == 'json':
|
||||
if isinstance(data, list) and len(data) == 1:
|
||||
data = data[0]
|
||||
data = json.loads(data)
|
||||
if data:
|
||||
self[key] = data
|
||||
|
||||
|
|
Loading…
Reference in a new issue