fastiot.util.object_helper module¶
- fastiot.util.object_helper.parse_object(dic, data_model)[source]¶
This function will help you convert a dictionary to an instance, of which the class inherits FastIoTData or BaseModel.
my_dict = {'name': 'test_dict', 'value': 123} obj = parse_object(my_dict, MyDataModel) >>> MyDataModel(name='test_dict', value=123)
- Return type:
Optional
[Type
[Union
[FastIoTData
,BaseModel
]]]
- fastiot.util.object_helper.parse_object_list(dict_list, data_model)[source]¶
This function helps you to convert a list of dictionaries to a list of instance, of which the class inherits FastIoTData or BaseModel
my_dict_list = [{'name': 'test_dict_1', 'value': 123}, {'name': 'test_dict_2', 'value': 23}] obj_list = parse_object_list(my_dict_list, MyDataModel) >>> [MyDataModel(name='test_dict_1', value=123), MyDataModel(name='test_dict_2', value=23)]
- Return type:
Optional
[List
[Type
[Union
[FastIoTData
,BaseModel
]]]]