本文整理汇总了Python中rapidjson.load方法的典型用法代码示例。如果您正苦于以下问题:Python rapidjson.load方法的具体用法?Python rapidjson.load怎么用?Python rapidjson.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson
的用法示例。
在下文中一共展示了rapidjson.load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_public_key
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def load_public_key(key_string: str) -> _RSAPublicKey:
"""
Load a public key from a string, which may be base64 encoded.
Parameters
----------
key_string : str
String containing the key, optionally base64 encoded
Returns
-------
_RSAPublicKey
The public key
"""
try:
return serialization.load_pem_public_key(
key_string.encode(), backend=default_backend()
)
except (ValueError, TypeError):
try:
return load_public_key(base64.b64decode(key_string).decode())
except (binascii.Error, ValueError):
raise ValueError("Failed to load key.")
示例2: create_daijin_validator
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def create_daijin_validator(simple=True):
cname = resource_filename("Mikado.configuration", "configuration_blueprint.json")
# We have to repeate twice the ending configuration (bug in jsonref?)
baseuri = "file://" + os.path.join(os.path.dirname(cname), os.path.basename(os.path.dirname(cname)))
with io.TextIOWrapper(resource_stream("Mikado.configuration",
"daijin_schema.json")) as blue:
blue_print = jsonref.load(blue,
jsonschema=True,
base_uri=baseuri)
# _substitute_conf(blue_print)
validator = extend_with_default(jsonschema.Draft7Validator,
simple=simple)
validator = validator(blue_print)
return validator
示例3: open
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def open(self, path, font=None):
with open(path, 'r') as file:
d = json.load(file)
assert self.version >= d.pop(".formatVersion")
if font is not None:
self._font = font
return self.structure(d, Font)
示例4: load_labels
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def load_labels(index):
"""index labels and return predicted output."""
labels_map = rjson.load(open("./data/labels_map.txt"))
labels = (labels_map[str(i)] for i in range(1000))
return next(islice(labels, index, None))
示例5: load
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def load(stream: bytes, *args, **kwargs) -> Dict:
kwargs = add_settings_to_kwargs(kwargs)
return rapidjson.load(stream, *args, **kwargs)
示例6: decompress_claims
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def decompress_claims(claims):
in_ = io.BytesIO()
in_.write(base64.decodebytes(claims.encode()))
in_.seek(0)
with gzip.GzipFile(fileobj=in_, mode="rb") as fo:
return json.load(fo)
# Duplicated in FlowAuth (cannot use this implementation there because
# this module is outside the docker build context for FlowAuth).
示例7: load_private_key
# 需要导入模块: import rapidjson [as 别名]
# 或者: from rapidjson import load [as 别名]
def load_private_key(key_string: str) -> _RSAPrivateKey:
"""
Load a private key from a string, which may be base64 encoded.
Parameters
----------
key_string : str
String containing the key, optionally base64 encoded
Returns
-------
_RSAPrivateKey
The private key
"""
try:
return serialization.load_pem_private_key(
key_string.encode(), password=None, backend=default_backend()
)
except ValueError:
try:
return load_private_key(base64.b64decode(key_string).decode())
except (binascii.Error, ValueError):
raise ValueError("Failed to load key.")
# Duplicated in FlowAPI (cannot use this implementation there because
# this module is outside the docker build context for FlowAuth).