@Converter
    public static Map<String, Object> toMap(final Struct struct) {
        final HashMap<String, Object> fieldsToValues = new HashMap<>();

        struct.schema().fields().forEach(field -> {
            Object value = struct.get(field);

            // recursive call if we have nested structs
            if (value instanceof Struct) {
                fieldsToValues.put(field.name(), toMap((Struct) value));
            } else {
                fieldsToValues.put(field.name(), value);
            }
        });

        return fieldsToValues;
    }
@Test
    void testToMapFromStruct() {
        final Struct inputValue = createTestStruct(12, "test-name", true);

        // convert toMap
        final Map<String, Object> outputValue = DebeziumTypeConverter.toMap(inputValue);

        // assert
        assertNotNull(outputValue);
        assertEquals(12, outputValue.get("id"));
        assertEquals("test-name", outputValue.get("name"));
        assertNull(outputValue.get("extra"));
        assertTrue((boolean) outputValue.get("valid"));
    }