def decode_struct(self, data_type, obj):
if obj is None and data_type.has_default():<EOL><INDENT>return data_type.get_default()<EOL><DEDENT>elif not isinstance(obj, dict):<EOL><INDENT>raise bv.ValidationError('<STR_LIT>' %<EOL>bv.generic_type_name(obj))<EOL><DEDENT>all_fields = data_type.definition._all_fields_<EOL>for extra_permission in self.caller_permissions.permissions:<EOL><INDENT>all_extra_fields = '<STR_LIT>'.format(extra_permission)<EOL>all_fields = all_fields + getattr(data_type.definition, all_extra_fields, [])<EOL><DEDENT>if self.strict:<EOL><INDENT>all_field_names = data_type.definition._all_field_names_<EOL>for extra_permission in self.caller_permissions.permissions:<EOL><INDENT>all_extra_field_names = '<STR_LIT>'.format(extra_permission)<EOL>all_field_names = all_field_names.union(<EOL>getattr(data_type.definition, all_extra_field_names, {}))<EOL><DEDENT>for key in obj:<EOL><INDENT>if (key not in all_field_names and<EOL>not key.startswith('<STR_LIT>')):<EOL><INDENT>raise bv.ValidationError("<STR_LIT>" % key)<EOL><DEDENT><DEDENT><DEDENT>ins = data_type.definition()<EOL>self.decode_struct_fields(ins, all_fields, obj)<EOL>data_type.validate_fields_only_with_permissions(ins, self.caller_permissions)<EOL>return ins<EOL>
The data_type argument must be a Struct.
See json_compat_obj_decode() for argument descriptions.