本文整理匯總了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)