• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python simplejson.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中simplejson.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _do_update_from_json

 def _do_update_from_json(
         self, json, parse_def, aliases, ctx, permissions,
         user_id, duplicate_error=True):
     # TODO: Verify uniqueness
     json_user_id = json.get('user', None)
     if json_user_id is None:
         json_user_id = user_id
     else:
         json_user_id = User.get_database_id(json_user_id)
         # Do not allow changing user
         if self.user_id is not None and json_user_id != self.user_id:
             raise HTTPBadRequest()
     self.user_id = json_user_id
     role_name = json.get("role", None)
     if not (role_name or self.role_id):
         role_name = R_PARTICIPANT
     if role_name:
         role = self.db.query(Role).filter_by(name=role_name).first()
         if not role:
             raise HTTPBadRequest("Invalid role name:"+role_name)
         self.role = role
     json_discussion_id = json.get('discussion', None)
     if json_discussion_id:
         from .discussion import Discussion
         json_discussion_id = Discussion.get_database_id(json_discussion_id)
         # Do not allow change of discussion
         if self.discussion_id is not None \
                 and json_discussion_id != self.discussion_id:
             raise HTTPBadRequest()
         self.discussion_id = json_discussion_id
     else:
         if not self.discussion_id:
             raise HTTPBadRequest()
     return self
开发者ID:iilab,项目名称:assembl,代码行数:34,代码来源:auth.py


示例2: dump_data

	def dump_data(self,json):
		self._count = json.get("count")
		self._hex_count = json.get("hexcodecount")
		self._name = json.get("name")

		self.set_count(self._count)
		self.set_hex_count(self._hex_count)
		self.set_name(self._name)
开发者ID:0day1day,项目名称:pdfxray_public,代码行数:8,代码来源:malobjclass.py


示例3: _set_artist

 def _set_artist(self, json):
     if json.get('artistId'):
         id = json['artistId']
         self.artist = Artist(id)
         self.artist._set(json)
     elif json.get('artistName'):
         self.artist = json['artistName']
     else:
         self.artist = None
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:9,代码来源:__init__.py


示例4: shallow_diver

	def shallow_diver(self,json,shell):
		for key, value in json.iteritems():
			if shell == key:
				data = json.get(shell)
				break
			else:
				if shell in value:
					data = json.get(key)
					data = self.shallow_diver(data,shell)
		return data
开发者ID:cvandeplas,项目名称:pdfxray,代码行数:10,代码来源:malobjclass.py


示例5: _set

    def _set(self, json):
        super(Album, self)._set(json)
        # Collection information
        self.name = json['collectionName']
        self.url = json.get('collectionViewUrl', None)
        self.amg_id = json.get('amgAlbumId', None)

        self.price = round(json.get('collectionPrice', 0) or 0, 4)
        self.price_currency = json['currency']
        self.track_count = json['trackCount']
        self.copyright = json.get('copyright', None)

        self._set_artist(json)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:13,代码来源:__init__.py


示例6: get_orders

def get_orders(url, params):
    json = get_json(url, params)
    # print json
    data = json.get("return")
    orders = data.get("bids"), data.get("asks")
    # print orders
    return orders
开发者ID:superxiaoqiang,项目名称:bitcoin,代码行数:7,代码来源:collector.py


示例7: _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)
开发者ID:paul-obrien,项目名称:python-itunes,代码行数:16,代码来源:__init__.py


示例8: get_orders2

def get_orders2(url):
    params = get_query_parameters(url)
    json = get_json(url, params)
    # print json
    data = json.get("return")
    if url.find("mtgox") != -1:
        bids = []
        bidsJson = data.get("bids")
        for bid in bidsJson:
            b = []
            b.append(bid.get("price"))
            b.append(bid.get("amount"))
            bids.append(b)

        asks = []
        asksJson = data.get("asks")
        for ask in asksJson:
            b = []
            b.append(ask.get("price"))
            b.append(ask.get("amount"))
            asks.append(b)

        return bids, asks
    else:
        orders = data.get("bids"), data.get("asks")
        # print orders
        return orders
开发者ID:superxiaoqiang,项目名称:bitcoin,代码行数:27,代码来源:collector.py


示例9: _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 'trackPrice' in json and json['trackPrice'] is not None:
         self.price = round(json['trackPrice'], 4)
     self.number = json.get('trackNumber', None)
     self.duration = None
     if 'trackTimeMillis' in json and json['trackTimeMillis'] is not None:
         self.duration = round(json.get('trackTimeMillis', 0.0)/1000.0, 2)
     try:
         self._set_artist(json)
     except KeyError:
         self.artist = None
     try:
         self._set_album(json)
     except KeyError:
         self.album = None
开发者ID:Smenus,项目名称:python-itunes,代码行数:21,代码来源:__init__.py


示例10: weixin_validate_data

    def weixin_validate_data(self, xml):
        json = {}
        for el in etree.fromstring(xml):
            json[el.tag] = el.text

        acquirer = request.env['payment.acquirer'].search(
            [('weixin_appid', '=', json.get('appid'))], limit=1
        )

        _KEY = acquirer.weixin_key
        _logger.info('weixin key: %s' % _KEY)
        if not _KEY:
            return False

        _, prestr = util.params_filter(json)
        mysign = util.build_mysign(prestr, _KEY, 'MD5')
        if mysign != json.get('sign'):
            return False

        _logger.info('weixin: data validated!')
        return True
开发者ID:jeffery9,项目名称:payment,代码行数:21,代码来源:main.py


示例11: weixin_validate_data

    def weixin_validate_data(self, **post):
        cr, uid, context = request.cr, request.uid, request.context
        json = {}
        for el in etree.fromstring(post):
            json[el.tag] = el.text

        _KEY = request.registry['payment.acquirer']._get_weixin_key()
        _, prestr = util.params_filter(json)
        mysign = util.build_mysign(prestr, _KEY, 'MD5')
        if mysign != json.get('sign'):
            return 'false'

        _logger.info('weixin: validated data')
        return request.registry['payment.transaction'].form_feedback(cr, SUPERUSER_ID, json, 'weixin',
                                                                     context=context)
开发者ID:Cgruppo,项目名称:payment,代码行数:15,代码来源:main.py


示例12: dump_data

	def dump_data(self,json):
		self._decoded = json.get("decoded")
		self._encoded = json.get("encoded")
		self._hex = json.get("hex")
		self._id = json.get("id")
		self._length = json.get("length")
		self._hash = json.get("md5")
		self._suspicious = json.get("suspicious")
		self._version = json.get("version")

		self.set_decoded(self._decoded)
		self.set_encoded(self._encoded)
		self.set_hex(self._hex)
		self.set_id(self._id)
		self.set_length(self._length)
		self.set_hash(self._hash)
		self.set_suspicious(self._suspicious)
		self.set_version(self._version)
开发者ID:7h3rAm,项目名称:malpdfobj,代码行数:18,代码来源:malobjclass.py


示例13: read

    def read(self, jsonld, discussion, admin_user_id, base=None):
        if isinstance(jsonld, (str, unicode)):
            jsonld = json.loads(jsonld)
        c = jsonld['@context']
        # Avoid loading the main context.
        if c == context_url:
            c = local_context_loc
        elif context_url in c:
            c.remove(context_url)
            c.append(local_context_loc)
        c = Context(c, base=base)
        by_id = dict()
        site_iri = None

        def find_objects(j):
            if isinstance(jsonld, (str, unicode)):
                return
            if isinstance(j, list):
                for x in j:
                    find_objects(x)
            if isinstance(j, dict):
                jid = j.get('@id', None)
                if jid:
                    by_id[jid] = j
                for x in j.values():
                    find_objects(x)
        find_objects(jsonld)
        for json in by_id.itervalues():
            if json.get('@type', None) == 'Site':
                site_iri = json['@id']
                break
        site_iri = site_iri or base
        assert site_iri is not None
        handler = ImportRecordHandler(discussion, site_iri)
        for json in by_id.itervalues():
            cls = self.class_from_type(json['@type'])
            if not cls:
                print "missing cls for :", json['@type']
                continue
            if cls:
                cls = get_named_class(cls)
            cls.create_from_json(
                json, admin_user_id, aliases=handler,
                parse_def_name='readcif.json', jsonld=by_id)
开发者ID:Lornz-,项目名称:assembl,代码行数:44,代码来源:jsonld_reader.py


示例14: update_from_json

 def update_from_json(self, json, user_id=Everyone, ctx=None):
     from ..auth.util import user_has_permission
     if user_has_permission(self.discussion_id, user_id, P_ADMIN_DISC):
         new_type = json.get('@type', self.type)
         if self.type != new_type:
             polymap = inspect(self.__class__).polymorphic_identity
             if new_type not in polymap:
                 return None
             new_type = polymap[new_type].class_
             new_instance = self.change_class(new_type)
             return new_instance.update_from_json(json, user_id, ctx)
         if 'settings' in json:
             self.settings_json = json['settings']
         if 'discussion' in json:
             self.discussion = Discussion.get_instance(json['discussion'])
     if 'state' in json:
         self.state_json = json['state']
     if user_id and user_id != Everyone and 'user_state' in json:
         self.set_user_state(json['user_state'], user_id)
     return self
开发者ID:hypnotics,项目名称:assembl,代码行数:20,代码来源:widgets.py


示例15: _set_genres

 def _set_genres(self, json):
     self.genres = json.get('genres', None)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:2,代码来源:__init__.py


示例16: _set_screenshots

 def _set_screenshots(self, json):
     self.screenshots = json.get('screenshotUrls', None)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:2,代码来源:__init__.py


示例17: _set_description

 def _set_description(self, json):
     self.description = json.get('description', None)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:2,代码来源:__init__.py


示例18: _set_price

 def _set_price(self, json):
     self.price = json.get('price', None)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:2,代码来源:__init__.py


示例19: _set_version

 def _set_version(self, json):
     self.version = json.get('version', None)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:2,代码来源:__init__.py


示例20: _set_artist

 def _set_artist(self, json):
     self.artist = None
     if json.get('artistId'):
         id = json['artistId']
         self.artist = Artist(id)
         self.artist._set(json)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:6,代码来源:__init__.py



注:本文中的simplejson.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python simplejson.has_key函数代码示例发布时间:2022-05-27
下一篇:
Python simplejson.dumps函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap