本文整理汇总了Python中boto3.dynamodb.types.TypeSerializer方法的典型用法代码示例。如果您正苦于以下问题:Python types.TypeSerializer方法的具体用法?Python types.TypeSerializer怎么用?Python types.TypeSerializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto3.dynamodb.types
的用法示例。
在下文中一共展示了types.TypeSerializer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from boto3.dynamodb import types [as 别名]
# 或者: from boto3.dynamodb.types import TypeSerializer [as 别名]
def __init__(self, transformer=None, condition_builder=None,
serializer=None, deserializer=None):
self._transformer = transformer
if transformer is None:
self._transformer = ParameterTransformer()
self._condition_builder = condition_builder
if condition_builder is None:
self._condition_builder = ConditionExpressionBuilder()
self._serializer = serializer
if serializer is None:
self._serializer = TypeSerializer()
self._deserializer = deserializer
if deserializer is None:
self._deserializer = TypeDeserializer()
示例2: dict_to_ddb
# 需要导入模块: from boto3.dynamodb import types [as 别名]
# 或者: from boto3.dynamodb.types import TypeSerializer [as 别名]
def dict_to_ddb(item):
# type: (Dict[str, Any]) -> Dict[str, Any]
# TODO: narrow these types down
"""Converts a native Python dictionary to a raw DynamoDB item.
:param dict item: Native item
:returns: DynamoDB item
:rtype: dict
"""
serializer = TypeSerializer()
return {key: serializer.serialize(value) for key, value in item.items()}
示例3: _serialize_deserialize_cycle
# 需要导入模块: from boto3.dynamodb import types [as 别名]
# 或者: from boto3.dynamodb.types import TypeSerializer [as 别名]
def _serialize_deserialize_cycle(attribute):
raw_attribute = TypeSerializer().serialize(attribute)
serialized_attribute = serialize_attribute(raw_attribute)
cycled_attribute = deserialize_attribute(serialized_attribute)
deserialized_attribute = TypeDeserializer().deserialize(cycled_attribute)
assert deserialized_attribute == attribute
示例4: dumps
# 需要导入模块: from boto3.dynamodb import types [as 别名]
# 或者: from boto3.dynamodb.types import TypeSerializer [as 别名]
def dumps(dct, as_dict=False, **kwargs):
""" Dump the dict to json in DynamoDB Format
You can use any other simplejson or json options
:param dct - the dict to dump
:param as_dict - returns the result as python dict (useful for DynamoDB boto3 library) or as json sting
:returns: DynamoDB json format.
"""
result_ = TypeSerializer().serialize(json.loads(json.dumps(dct, default=json_serial),
use_decimal=True))
if as_dict:
return next(six.iteritems(result_))[1]
else:
return json.dumps(next(six.iteritems(result_))[1], **kwargs)