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

Python json.loads函数代码示例

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

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



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

示例1: verify

 def verify(self):
     self.fp.seek(0)
     try:
         cont = self.fp.read()
         json.loads(cont)
         isB64 = True
     except (UnicodeDecodeError,ValueError):
         isB64 = False
     return isB64
开发者ID:HelderMagalhaes,项目名称:qooxdoo,代码行数:9,代码来源:Image.py


示例2: verify

 def verify(self):
     self.fp.seek(0)
     cont = self.fp.read()
     try:
         json.loads(cont)
         isB64 = True
     except ValueError:
         isB64 = False
     return isB64
开发者ID:dominikg,项目名称:qooxdoo,代码行数:9,代码来源:Image.py


示例3: toResinfo

 def toResinfo(self):
     result = super(self.__class__, self).toResinfo()
     if self.format == "b64" and self.path:
         cont = filetool.read(self.path)
         cont = json.loads(cont)
         result.append(cont)
     return result
开发者ID:HelderMagalhaes,项目名称:qooxdoo,代码行数:7,代码来源:CombinedImage.py


示例4: __init__

 def __init__(self, path):
     mf = codecs.open(path, "r", "utf-8")
     manifest = json.loads(mf.read())
     mf.close()
     self._manifest = manifest
     libinfo       = self._manifest['info']
     libprovides   = self._manifest['provides']
     self.classpath = libprovides['class']
     self.translation = libprovides['translation']
     self.namespace = libprovides['namespace']
     self.encoding = libprovides['encoding']
     self.resource = libprovides['resource']
     self.type = libprovides['type']
开发者ID:hu198021688500,项目名称:joomtu,代码行数:13,代码来源:Manifest.py


示例5: getSchema

    def getSchema(self):
        relPathToSchema = "/../../../data/config/config_schema.json"
        schemaPath = os.path.abspath(os.path.dirname(__file__) + relPathToSchema)

        try:
            file = codecs.open(schemaPath, "r", "utf-8")
            schema = json.loads(file.read())
            file.close()
        except Exception, e:
            msg = "Reading of schema file failed: '%s'" % schemaPath + (
                "\n%s" % e.args[0] if e.args else "")
            e.args = (msg,) + e.args[1:]
            raise
开发者ID:Amsoft-Systems,项目名称:qooxdoo,代码行数:13,代码来源:Config.py


示例6: parseMetaFile

 def parseMetaFile(self, path):
     # Read the .meta file
     # it doesn't seem worth to apply caching here
     meta_fname   = os.path.splitext(path)[0]+'.meta'
     try:
         meta_content = filetool.read(meta_fname)
         fontDict      = json.loads(meta_content)
     except Exception, e:
         msg = "Reading of .meta file failed: '%s'" % meta_fname + (
             "\n%s" % e.args[0] if e.args else ""
             )
         e.args = (msg,) + e.args[1:]
         raise
开发者ID:RemiHeugue,项目名称:qooxdoo,代码行数:13,代码来源:FontMap.py


示例7: toResinfo

 def toResinfo(self):
     result = super(self.__class__, self).toResinfo()
     if self.format == "b64" and self.path:
         try:
             cont = filetool.read(self.path)
             cont = json.loads(cont)
         except Exception, e:
             msg = "Reading of b64 image file failed: '%s'" % self.path + (
                 "\n%s" % e.args[0] if e.args else ""
                 )
             e.args = (msg,) + e.args[1:]
             raise
         else:
             result.append(cont)
开发者ID:RemiHeugue,项目名称:qooxdoo,代码行数:14,代码来源:CombinedImage.py


示例8: parseMetaFile

    def parseMetaFile(self, path):
        # Read the .meta file
        # it doesn't seem worth to apply caching here
        meta_fname   = os.path.splitext(path)[0]+'.meta'
        meta_content = filetool.read(meta_fname)
        imgDict      = json.loads(meta_content)

        # Loop through the images of the .meta file
        for imageId, imageSpec_ in imgDict.items():
            # sort of like this: imageId : [width, height, type, combinedUri, off-x, off-y]
            imageObject = Image()
            imageObject.id = imageId
            imageObject = imageObject.fromMeta(imageSpec_)
            self.embeds.append(imageObject)
        return
开发者ID:HelderMagalhaes,项目名称:qooxdoo,代码行数:15,代码来源:CombinedImage.py


示例9: getQxPath

def getQxPath():
    path = QOOXDOO_PATH
    # OS env takes precedence
    if os.environ.has_key("QOOXDOO_PATH"):
        path = os.environ["QOOXDOO_PATH"]

    # else use QOOXDOO_PATH from config.json
    else:
        config_file = ShellOptions.config
        if os.path.exists(config_file):
            # try json parsing with qx json
            if not path.startswith("${"):  # template macro has been resolved
                sys.path.insert(0, os.path.join(path, QX_PYLIB))
                try:
                    from misc import json

                    got_json = True
                except:
                    got_json = False

            got_path = False
            if got_json:
                config_str = codecs.open(config_file, "r", "utf-8").read()
                config_str = stripComments(config_str)
                config = json.loads(config_str)
                p = config.get("let")
                if p:
                    p = p.get("QOOXDOO_PATH")
                    if p:
                        path = p
                        got_path = True

            # regex parsing - error prone
            if not got_path:
                qpathr = re.compile(r'"QOOXDOO_PATH"\s*:\s*"([^"]*)"\s*,?')
                conffile = codecs.open(config_file, "r", "utf-8")
                aconffile = conffile.readlines()
                for line in aconffile:
                    mo = qpathr.search(line)
                    if mo:
                        path = mo.group(1)
                        break  # assume first occurrence is ok

    path = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), path))

    return path
开发者ID:salmon-charles,项目名称:qooxdoo-archetype-desktop,代码行数:46,代码来源:generate.py


示例10: parseTestJson

def parseTestJson(jsonString):
    apps = {}
    jData = json.loads(jsonString)
    format_in = "%Y-%m-%d_%H-%M-%S" 
    format_out = "%Y-%m-%d_%H:%M:%S" 
    for app, appVals in jData.items():
        if appVals['BuildError'] != None:
            continue
        apps[app] = {}
        # build start time
        stime = datetime.datetime.strptime(appVals['BuildStarted'], format_in)
        apps[app]['stime'] = stime.strftime(format_out)
        # build end time
        etime = datetime.datetime.strptime(appVals['BuildFinished'], format_in)
        apps[app]['etime'] = etime.strftime(format_out)
        # build duration in secs
        apps[app]['duration'] = timedelta_to_seconds(etime - stime)

    return apps
开发者ID:aparusel,项目名称:qooxdoo,代码行数:19,代码来源:nightly_build_times.py


示例11: take_action

 def take_action(self, action, dest, opt, value, values, parser):
     if action == "extend":
         lvalue = value.split(",")
         while "" in lvalue:
             lvalue.remove("")
         values.ensure_value(dest, []).extend(lvalue)
     elif action == "map":
         keyval = value.split(":", 1)
         if len(keyval) == 2 and len(keyval[0]) > 0:
             if keyval[1][0] in ["[", "{"]: # decode a Json value
                 val = json.loads(keyval[1])
             else:
                 val = keyval[1]
             values.ensure_value(dest, {})[keyval[0]] = val
         else:
             raise OptionValueError("Value has to be of the form '<key>:<val>': %s" % value)
     else:
         Option.take_action(
             self, action, dest, opt, value, values, parser)
开发者ID:1and1,项目名称:qooxdoo,代码行数:19,代码来源:ExtendAction.py


示例12: CreateDemoJson

def CreateDemoJson():

    source = []
    build  = []
    scategories = {}
    bcategories = {}

    # Pre-processing
    JSON = {}
    # top-level includes
    default_json = 'tool' + '/' + 'default.json'
    assert os.path.isfile(default_json)
    JSON['include'] = [{ "path" : "%s" % default_json }]

    # per-demo template file
    json_tmpl = open(os.path.join('tool','tmpl.json'),"rU").read()

    # jobs section
    JSON['jobs'] = {}

    # Process demo html files
    while True:
        html = (yield)
        #print html
        if html == None:  # terminate the generator part and go to finalizing json file
            break

        category, name = demoCategoryFromFile(html)
        #print ">>> Processing: %s.%s..." % (category, name)

        # check for demo-specific config file
        config_file = os.path.splitext(html)[0] + ".json"
        if os.path.exists(config_file):
            JSON['include'].append({"path":"%s" % config_file})

        # build classname
        simple = "%s.%s" % (category,name)
        source.append("source-%s" % simple)
        build.append("build-%s" % simple)
        if not category in scategories:
            scategories[category] = []
        scategories[category].append("source-%s" % (simple,))
        if not category in bcategories:
            bcategories[category] = []
        bcategories[category].append("build-%s" % (simple,))

        # concat all
        currcont = json_tmpl.replace('XXX',"%s.%s"%(category,name)).replace("YYY",name).replace("ZZZ",category)
        templatejobs = json.loads("{" + currcont + "}")
        for job,jobval in templatejobs.iteritems():
            JSON['jobs'][job] = jobval

    # Post-processing
    for category in scategories:
        currentry = JSON['jobs']["source-%s" % category] = {}
        currentry['run'] = sorted(scategories[category])
        currentry = JSON['jobs']["build-%s" % category] = {}
        currentry['run'] = sorted(bcategories[category])

    JSON['jobs']["source"] = { "run" : sorted(source) }
    JSON['jobs']["build"]  = { "run" : sorted(build) }

    cont = '// This file is dynamically created by the generator!\n'
    cont += json.dumps(JSON, sort_keys=True, indent=2)
    filetool.save(fJSON, cont)

    yield  # final yield to provide for .send(None) of caller
开发者ID:vuuvv,项目名称:vshop1,代码行数:67,代码来源:gendata.py


示例13: CreateDemoJson

def CreateDemoJson(dest, qxdir):
    source = []
    build  = []
    scategories = {}
    bcategories = {}

    # Pre-processing
    JSON = {}
    # top-level includes

    default_json = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])) , 'default.json')
    assert os.path.isfile(default_json)
    JSON['include'] = [{ "path" : "%s" % default_json }]

    # per-demo template file
    tmpl_json = os.path.join(os.path.dirname(sys.argv[0]) , 'tmpl.json')
    tmpl_manifest = os.path.join(os.path.dirname(sys.argv[0]) , TMPL_MANIFEST)
    tmpl_config = os.path.join(os.path.dirname(sys.argv[0]) , TMPL_CONFIG)

    json_tmpl = open(tmpl_json,"rU").read()

    demo_ns = "%s.demo" % namespace

    manifest_tmpl = json.loads(open(tmpl_manifest, 'rU').read())
    manifest_tmpl['provides']['namespace'] = demo_ns

    config_tmpl = json.loads(open(tmpl_config, 'rU').read())
    config_tmpl['let']['QOOXDOO_PATH'] = os.path.join('..', qxdir)
    config_tmpl['jobs']['source-demos']['let']['APPLICATION'] = demo_ns

    fn = os.path.basename(tmpl_manifest)[len('tmpl.'):] # file name
    open(os.path.join(dest, '..', '..', fn), 'w').write(json.dumps(manifest_tmpl, indent=2, sort_keys=True))

    fn = os.path.basename(tmpl_config)[len('tmpl.'):]
    open(os.path.join(dest, '..', '..', fn), 'w').write(json.dumps(config_tmpl, indent=2, sort_keys=True))

    # jobs section
    JSON['jobs'] = {}

    # allow exported jobs to be shadowed
    JSON['config-warnings'] = {}
    shadowed_jobs = []
    JSON['config-warnings']['job-shadowing'] = shadowed_jobs

    # Process demo html files
    while True:
        html = (yield)
        #print html
        if html == None:  # terminate the generator part and go to finalizing json file
            break

        category, name = demoCategoryFromFile(html)
        #print ">>> Processing: %s.%s..." % (category, name)

        # check for demo-specific config file
        config_file = os.path.splitext(html)[0] + ".json"
        if os.path.exists(config_file):
            JSON['include'].append({"path":"%s" % config_file})
            demo_config = json.loadStripComments(config_file)
            shadowed_jobs.extend(demo_config['export'])

        # build classname
        simple = "%s.%s" % (category,name)
        source.append("source-%s" % simple)
        build.append("build-%s" % simple)
        if not category in scategories:
            scategories[category] = []
        scategories[category].append("source-%s" % (simple,))
        if not category in bcategories:
            bcategories[category] = []
        bcategories[category].append("build-%s" % (simple,))

        # concat all
        currcont = json_tmpl.replace('XXX',"%s.%s"%(category,name)).replace("YYY",name).replace("ZZZ",category)
        templatejobs = json.loads("{" + currcont + "}")
        for job,jobval in templatejobs.iteritems():
            JSON['jobs'][job] = jobval

    # Post-processing
    for category in scategories:
        currentry = JSON['jobs']["source-%s" % category] = {}
        currentry['run'] = sorted(scategories[category])
        currentry = JSON['jobs']["build-%s" % category] = {}
        currentry['run'] = sorted(bcategories[category])

    JSON['jobs']["source"] = { "run" : sorted(source) }
    JSON['jobs']["build"]  = { "run" : sorted(build) }

    cont = '// This file is dynamically created by the generator!\n'
    cont += json.dumps(JSON, sort_keys=True, indent=2)
    filetool.save(os.path.join('demobrowser', fJSON), cont)

    yield  # final yield to provide for .send(None) of caller
开发者ID:plq,项目名称:qooxdoo,代码行数:93,代码来源:gendata.py


示例14: manifest_from_url

 def manifest_from_url(self, url):
     urlobj = urllib.urlopen(url) # urllib does handle https
     assert urlobj.getcode() == 200, "Could not access the contrib catalog URL: %s" % url
     manifest = urlobj.read()
     manifest = ExtMap(json.loads(manifest))
     return manifest
开发者ID:VitalHealthSoftware,项目名称:qooxdoo,代码行数:6,代码来源:ContribLoader.py


示例15: execfile

##
# syntax: $0 <file.js> -- parse JS file and write it to console again
# 
# An experimental hybrid deserializer-serializer that uses 'esparse' to parse
# the JS, then uses a Moz AST to treegenerator_1 AST transformer, and writes out
# the resulting tree.
## 

import re, os, sys, types, codecs
QOOXDOO_PATH = os.path.abspath(os.path.dirname(__file__) + "/../../../..")
execfile(QOOXDOO_PATH + "/tool/bin/qxenviron.py")
from ecmascript.transform import moztree_to_tree1
from generator.runtime.ShellCmd import ShellCmd
from misc import json

shell = ShellCmd()
cmd = "esparse --raw --loc " + sys.argv[1]
#print cmd
rcode, stdout, errout = (
    shell.execute_piped(cmd))
if rcode != 0:
    print errout
    sys.exit(1)
tree_json = json.loads(stdout)
node = moztree_to_tree1.esprima_to_tree1(tree_json)
#print node.toXml()
#import pydb; pydb.debugger()
def opts():pass
opts.breaks = False
print node.toJS(opts)
开发者ID:1and1,项目名称:qooxdoo,代码行数:30,代码来源:compile_hyb.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python run_cmd.call函数代码示例发布时间:2022-05-27
下一篇:
Python json.dumpsCode函数代码示例发布时间: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