本文整理汇总了Python中simplejson.has_key函数的典型用法代码示例。如果您正苦于以下问题:Python has_key函数的具体用法?Python has_key怎么用?Python has_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_key函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_url
def _set_url(self, json):
self.url = None
if json.has_key('trackViewUrl'):
self.url = json['trackViewUrl']
elif json.has_key('collectionViewUrl'):
self.url = json['collectionViewUrl']
elif json.has_key('artistViewUrl'):
self.url = json['artistViewUrl']
示例2: _set_artwork
def _set_artwork(self, json):
self.artwork = dict()
if json.has_key('artworkUrl30'):
self.artwork['30'] = json['artworkUrl30']
if json.has_key('artworkUrl60'):
self.artwork['60'] = json['artworkUrl60']
if json.has_key('artworkUrl100'):
self.artwork['100'] = json['artworkUrl100']
if json.has_key('artworkUrl512'):
self.artwork['512'] = json['artworkUrl512']
示例3: _set
def _set(self, json):
super(Track, self)._set(json)
# Track information
self.name = json['trackName']
self.url = json.get('trackViewUrl', None)
self.preview_url = json.get('previewUrl', None)
self.price = None
if json.has_key('trackPrice') and json['trackPrice'] is not None:
self.price = round(json['trackPrice'], 4)
self.number = json.get('trackNumber', None)
self.duration = None
if json.has_key('trackTimeMillis') and json['trackTimeMillis'] is not None:
self.duration = round(json.get('trackTimeMillis', 0.0)/1000.0, 2)
self._set_artist(json)
self._set_album(json)
示例4: get
def get(self):
self._json_results = self._request(cacheable=is_caching_enabled())
if self._json_results.has_key('errorMessage'):
raise ServiceException(type='Error', message=self._json_results['errorMessage'])
self._num_results = self._json_results['resultCount']
l = []
for json in self._json_results['results']:
type = None
if json.has_key('wrapperType'):
type = json['wrapperType']
elif json.has_key('kind'):
type = json['kind']
if type == 'artist':
id = json['artistId']
item = Artist(id)
elif type == 'collection':
id = json['collectionId']
item = Album(id)
elif type == 'track':
id = json['trackId']
item = Track(id)
elif type == 'audiobook':
id = json['collectionId']
item = Audiobook(id)
elif type == 'ebook':
id = json['trackId']
item = Ebook(id)
elif type == 'software':
id = json['trackId']
item = Software(id)
else:
if json.has_key('collectionId'):
id = json['collectionId']
elif json.has_key('artistId'):
id = json['artistId']
item = Item(id)
item._set(json)
l.append(item)
return l
示例5: _set
def _set(self, json):
self.json = json
#print json
if json.has_key('kind'):
self.type = json['kind']
else:
self.type = json['wrapperType']
# Item information
self._set_genre(json)
self._set_release(json)
self._set_country(json)
self._set_artwork(json)
self._set_url(json)
示例6: __init__
def __init__(self, id=None, json=None, username=None, token=None):
self.id = id
self._json = json
self._username = username
self._token = token
# Map given repo id to gist id if none exists
if self._json:
self.id = json["repo"] if json.has_key("repo") else json["id"]
self.url = url = GIST_BASE % self.id
self.embed_url = url + ".js"
self.epic_embed_url = url + ".pibb"
self.json_url = url + ".json"
self.post_url = GIST_BASE % "gists/%s" % self.id
示例7: _simplify_json
def _simplify_json(self, json):
result = {}
# First, resolve references
for element in json.values():
for k,v in element.items():
if isinstance(v, unicode) and v.startswith("http://") and json.has_key(v):
element[k] = json[v]
for k, v in json.items():
if v.has_key("_typeGroup"):
group = v["_typeGroup"]
if not result.has_key(group):
result[group]=[]
del v["_typeGroup"]
v["__reference"] = k
result[group].append(v)
return result
示例8: _set_album
def _set_album(self, json):
if json.has_key('collectionId'):
id = json['collectionId']
self.album = Album(id)
self.album._set(json)
示例9: _set_release
def _set_release(self, json):
self.release_date = None
if json.has_key('releaseDate') and json['releaseDate']:
self.release_date = json['releaseDate'].split('T')[0]
示例10: _set_current_version_release_date
def _set_current_version_release_date(self, json):
self.current_version_release_date = None
if json.has_key('currentVersionReleaseDate') and json['currentVersionReleaseDate']:
self.current_version_release_date = datetime.datetime.strptime( json['currentVersionReleaseDate'], r'%Y-%m-%dT%H:%M:%SZ' )