@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 testToMapNestedStruct() {
        Schema detailsSchema = SchemaBuilder.struct().field("age", SchemaBuilder.INT32_SCHEMA).build();

        Schema valueSchema = SchemaBuilder.struct()
                .name("valueSchema")
                .field("id", SchemaBuilder.INT32_SCHEMA)
                .field("name", SchemaBuilder.STRING_SCHEMA)
                .field("isAdult", SchemaBuilder.BOOLEAN_SCHEMA)
                .field("details", detailsSchema)
                .build();

        Struct inputValue = new Struct(valueSchema)
                .put("id", 12)
                .put("name", "jane doe")
                .put("isAdult", true)
                .put("details", new Struct(detailsSchema).put("age", 30));

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

        assertEquals("jane doe", outputValue.get("name"));
        assertEquals(12, outputValue.get("id"));
        assertTrue((Boolean) outputValue.get("isAdult"));
        assertEquals(30, ((Map) outputValue.get("details")).get("age"));
    }