@@ -336,8 +336,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None):
336336 """
337337 deserializer = Deserializer (cls ._infer_class_models ())
338338 deserializer .key_extractors = [
339- rest_key_case_insensitive_extractor ,
340339 attribute_key_case_insensitive_extractor ,
340+ rest_key_case_insensitive_extractor ,
341341 last_rest_key_case_insensitive_extractor
342342 ] if key_extractors is None else key_extractors
343343 return deserializer (cls .__name__ , data , content_type = content_type )
@@ -1160,11 +1160,17 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data):
11601160 return attribute_key_case_insensitive_extractor (key , None , working_data )
11611161
11621162def last_rest_key_extractor (attr , attr_desc , data ):
1163+ """Extract the attribute in "data" based on the last part of the JSON path key.
1164+ """
11631165 key = attr_desc ['key' ]
11641166 dict_keys = _FLATTEN .split (key )
11651167 return attribute_key_extractor (dict_keys [- 1 ], None , data )
11661168
11671169def last_rest_key_case_insensitive_extractor (attr , attr_desc , data ):
1170+ """Extract the attribute in "data" based on the last part of the JSON path key.
1171+
1172+ This is the case insensitive version of "last_rest_key_extractor"
1173+ """
11681174 key = attr_desc ['key' ]
11691175 dict_keys = _FLATTEN .split (key )
11701176 return attribute_key_case_insensitive_extractor (dict_keys [- 1 ], None , data )
@@ -1259,8 +1265,8 @@ def xml_key_extractor(attr, attr_desc, data):
12591265class Deserializer (object ):
12601266 """Response object model deserializer.
12611267
1262- :param dict classes: Class type dictionary for deserializing
1263- complex types .
1268+ :param dict classes: Class type dictionary for deserializing complex types.
1269+ :ivar list key_extractors: Ordered list of extractors to be used by this deserializer .
12641270 """
12651271
12661272 basic_types = {str : 'str' , int : 'int' , bool : 'bool' , float : 'float' }
@@ -1375,7 +1381,15 @@ def _deserialize(self, target_obj, data):
13751381 found_value = key_extractor (attr , attr_desc , data )
13761382 if found_value is not None :
13771383 if raw_value is not None and raw_value != found_value :
1378- raise KeyError ('Use twice the key: "{}"' .format (attr ))
1384+ msg = ("Ignoring extracted value '%s' from %s for key '%s'"
1385+ " (duplicate extraction, follow extractors order)" )
1386+ _LOGGER .warning (
1387+ msg ,
1388+ found_value ,
1389+ key_extractor ,
1390+ attr
1391+ )
1392+ continue
13791393 raw_value = found_value
13801394
13811395 value = self .deserialize_data (raw_value , attr_desc ['type' ])
0 commit comments