本文整理汇总了Python中msrest.Serializer.serialize_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Serializer.serialize_dict方法的具体用法?Python Serializer.serialize_dict怎么用?Python Serializer.serialize_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msrest.Serializer
的用法示例。
在下文中一共展示了Serializer.serialize_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRuntimeSerialized
# 需要导入模块: from msrest import Serializer [as 别名]
# 或者: from msrest.Serializer import serialize_dict [as 别名]
#.........这里部分代码省略.........
self.assertEqual(d, 100.0123)
def test_serialize_object(self):
a = self.s.body(1, 'object')
self.assertEqual(a, 1)
b = self.s.body(True, 'object')
self.assertEqual(b, True)
c = self.s.serialize_data('True', 'object')
self.assertEqual(c, 'True')
d = self.s.serialize_data(100.0123, 'object')
self.assertEqual(d, 100.0123)
e = self.s.serialize_data({}, 'object')
self.assertEqual(e, {})
f = self.s.body({"test":"data"}, 'object')
self.assertEqual(f, {"test":"data"})
g = self.s.body({"test":{"value":"data"}}, 'object')
self.assertEqual(g, {"test":{"value":"data"}})
h = self.s.serialize_data({"test":self.TestObj()}, 'object')
self.assertEqual(h, {"test":"Test_Object"})
i = self.s.serialize_data({"test":[1,2,3,4,5]}, 'object')
self.assertEqual(i, {"test":[1,2,3,4,5]})
def test_serialize_empty_iter(self):
a = self.s.serialize_dict({}, 'int')
self.assertEqual(a, {})
b = self.s.serialize_iter([], 'int')
self.assertEqual(b, [])
def test_serialize_json_obj(self):
class ComplexId(Model):
_validation = {}
_attribute_map = {'id':{'key':'id','type':'int'},
'name':{'key':'name','type':'str'},
'age':{'key':'age','type':'float'},
'male':{'key':'male','type':'bool'},
'birthday':{'key':'birthday','type':'iso-8601'},
'anniversary':{'key':'anniversary', 'type':'iso-8601'}}
id = 1
name = "Joey"
age = 23.36
male = True
birthday = '1992-01-01T00:00:00.000Z'
anniversary = isodate.parse_datetime('2013-12-08T00:00:00')
class ComplexJson(Model):
_validation = {}
_attribute_map = {'p1':{'key':'p1','type':'str'},
'p2':{'key':'p2','type':'str'},
'top_date':{'key':'top_date', 'type':'iso-8601'},
'top_dates':{'key':'top_dates', 'type':'[iso-8601]'},
'insider':{'key':'insider','type':'{iso-8601}'},