@@ -677,17 +677,28 @@ ReturnCode_t json_deserialize_enum_member(
677677 enum_type = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_desc->type ())->resolve_alias_enclosed_type ();
678678 }
679679
680- if (nullptr == enum_type)
680+ // if (nullptr == enum_type)
681+ // {
682+ // EPROSIMA_LOG_ERROR(XTYPES_UTILS,
683+ // "Error encountered while deserializing TK_ENUM member from JSON: null enum type.");
684+ // return RETCODE_BAD_PARAMETER;
685+ // }
686+
687+ // Get enclosing type kind to parse the value accordingly, and later user the appropriate setter
688+ assert (enum_type->get_kind () == TK_ENUM );
689+ // TypeKind enclosing_kind = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_type->get_all_members_by_index().at(
690+ // 0)->get_descriptor().type())->get_kind(); // Unfortunately DynamicDataImpl::get_enclosing_typekind is private
691+ auto enum_members = enum_type->get_all_members_by_index ();
692+ auto enum_desc = enum_members.at (0 )->get_descriptor ();
693+ auto enum_member_type = enum_desc.type ();
694+ auto enum_member_type_impl = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_member_type);
695+ if (nullptr == enum_member_type_impl)
681696 {
682697 EPROSIMA_LOG_ERROR (XTYPES_UTILS ,
683- " Error encountered while deserializing TK_ENUM member from JSON: null enum type." );
698+ " Error encountered while deserializing TK_ENUM member from JSON: null enum member type." );
684699 return RETCODE_BAD_PARAMETER ;
685700 }
686-
687- // Get enclosing type kind to parse the value accordingly, and later user the appropriate setter
688- assert (enum_type->get_kind () == TK_ENUM );
689- TypeKind enclosing_kind = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_type->get_all_members_by_index ().at (
690- 0 )->get_descriptor ().type ())->get_kind (); // Unfortunately DynamicDataImpl::get_enclosing_typekind is private
701+ TypeKind enclosing_kind = enum_member_type_impl->get_kind ();
691702
692703 if (DynamicDataJsonFormat::OMG == format)
693704 {
0 commit comments