title: mapstruct convert list to map
body: <p>I am a very new to mapstruct. I am trying to convert List to Map, I've searched a lot online, I've got some solutions like its not yet implemented in mapstruct seems. I will be glad if someone could able to provide some alternative solution. 
  All I am looking to convert mapping as below:</p>
  
  <pre><code>@Mapping
  Map&lt;String, Object&gt; toMap(List&lt;MyObj&gt;)
  
  @Mapping
      List&lt;MyObj&gt; toList(Map&lt;String, Object&gt;)
  </code></pre>
  
  <p>where <strong>MyObj</strong> as below:</p>
  
  <pre><code>class MyObj {
    String key; //map key
    String value; //map value
    String field1;
  }
  </code></pre>
  
  <p>In above, only use key and value fields from MyObj class. I've found one solution but below is converting some object to MAP, but using Jackson below:</p>
  
  <pre><code>@Mapper
  public interface ModelMapper {
  
    ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  
    default HashMap&lt;String, Object&gt; toMap(Object filter) {
      TypeFactory typeFactory = OBJECT_MAPPER.getTypeFactory();
      return OBJECT_MAPPER.convertValue(filter, typeFactory.constructMapType(Map.class, String.class, Object.class));
    }
  }
  </code></pre>
  
  <p>is there  anyway now to implement using mapstruct?</p>