title: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: java.lang.String cannot be cast to java.lang.Enum
body: <p>I have a Spring boot application.
  spring-boot-starter-parent 2.3.0.RELEASE</p>
  
  <p>I'm trying to get a list of objects and expect to get something like this:</p>
  
  <pre><code>{
      "items": [
          {
              "role": "MASTER",
              "module": "USER_EDIT",
              "permissions": [
                   "READ", "WRITE"
              ]
          }
      ],
      "total": 1
  }
  </code></pre>
  
  <p>But I receive an exception:</p>
  
  <pre><code>org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: 
  java.lang.String cannot be cast to java.lang.Enum; nested exception is com.fasterxml.jackson.databind.JsonMappingException: java.lang.String cannot be cast to java.lang.Enum (through reference chain: com.myproject.dto.ListDto["items"]-&gt;java.util.ArrayList[0]-&gt;com.myproject.dto.PermissionDto["permissions"]-&gt;java.util.ArrayList[0])
  ...
  Caused by: com.fasterxml.jackson.databind.JsonMappingException: java.lang.String cannot be cast to java.lang.Enum (through reference chain: com.myproject.dto.ListDto["items"]-&gt;java.util.ArrayList[0]-&gt;com.myproject.dto.PermissionDto["permissions"]-&gt;java.util.ArrayList[0])
  at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:397)
  at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:368)
  at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:338)
  at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContentsUsing(IndexedListSerializer.java:148)
  ...
  Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Enum
  at com.fasterxml.jackson.databind.ser.std.EnumSerializer.serialize(EnumSerializer.java:27)
  at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContentsUsing(IndexedListSerializer.java:142)
  ...
  </code></pre>
  
  <p><strong>Api method</strong>:</p>
  
  <pre><code>@GetMapping
  public ListDto&lt;PermissionDto&gt; permissions() {
      return new ListDto&lt;&gt;(permissionsService.list(), permissionsService.count());
  }
  </code></pre>
  
  <p><strong>ListDto</strong>:</p>
  
  <pre><code>@Data
  @AllArgsConstructor
  public class ListDto&lt;T&gt; {
      private List&lt;T&gt; items;
      private long total;
  }
  </code></pre>
  
  <p><strong>PermissionDto</strong>:</p>
  
  <pre><code>@Data
  public class PermissionDto {
      private Role role;
      private Module module;
      private List&lt;Permission&gt; permissions;
  }
  </code></pre>
  
  <p><strong>Permission</strong>:</p>
  
  <pre><code>public enum Permission {
      READ,
      WRITE,
      UPDATE,
      DELETE;
  }
  </code></pre>