title: How to make a TypeConverter in Room from a custom list?
body: <p>I have made a TypeConverter but I get an error</p>
  
  <blockquote>
    <p>Unable to create converter for class
    .models.lastanime.EpisodesEntityfor method EpisodesApi.getEpisodes</p>
  </blockquote>
  
  <p>I can't finish understanding how to make the TypeConverter, I have done this, I know that the implementation is placed correctly since I have not had problems in the compilation, but the data does not load since I get an error, and it seems that it is not saved in the room database</p>
  
  <p><strong>TYPE CONVERTER</strong></p>
  
  <pre><code>class ListStringConverter {
  
      @TypeConverter
      fun fromString(value: String?): List&lt;ServerEntity&gt; {
          val listType = object :
              TypeToken&lt;List&lt;ServerEntity?&gt;?&gt;() {}.type
          return Gson()
              .fromJson&lt;List&lt;ServerEntity&gt;&gt;(value, listType)
      }
  
      @TypeConverter
      fun listToString(list: List&lt;ServerEntity?&gt;?): String {
          val gson = Gson()
          return gson.toJson(list)
      }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>MODEL EPISODES ENTITY</strong></p>
  
  <pre><code>data class EpisodesEntity(
  @SerializedName("episodes")
  val episodes: List&lt;EpisodeEntity&gt;
  </code></pre>
  
  <p>)</p>
  
  <p><strong>MODEL EPISODE ENTITY</strong></p>
  
  <pre><code>@Entity
  data class EpisodeEntity(
  
      @PrimaryKey(autoGenerate = true)
      val id: Int,
  
      @SerializedName("poster")
      @ColumnInfo(name = "episode")
      val episode: Int?,
  
      @SerializedName("poster")
      @ColumnInfo(name = "poster")
      val poster: String?,
  
      @SerializedName("servers")
      @ColumnInfo(name = "servers")
      val servers: List&lt;ServerEntity&gt;?,
  
      @SerializedName("title")
      @ColumnInfo(name = "title")
      val title: String?
  
  )
  </code></pre>
  
  <p>In addition to all the model, the list of Servers is what gives me trouble inserting it in room</p>
  
  <pre><code>@SerializedName("servers")
      @ColumnInfo(name = "servers")
      val servers: List&lt;ServerEntity&gt;?,
  </code></pre>
  
  <p><strong>API REPOSITORY</strong></p>
  
  <pre><code>interface LastEpisodesRepository {
  
  fun lastEpisodes(): Flow&lt;Either&lt;Failure, List&lt;Episode&gt;&gt;&gt;
  
  class Network(
      private val networkHandler: NetworkHandler,
      private val service: LastEpisodesService,
      private val local: EpisodeLocal
  ) : LastEpisodesRepository {
  
      val preferences by lazy { SharedPrefsHelpers() }
  
      override fun lastEpisodes(): Flow&lt;Either&lt;Failure, List&lt;Episode&gt;&gt;&gt; =
          flow {
  
              val days = local.getEpisodes()
              val time = preferences.getLong(LocalShared.LastAnimes.lastepisodes, 0L)
  
              if (days.isNullOrEmpty() || time == 0L || isFetchCurrentNeeded(time)) {
                  emit(getRemoteDay())
              } else {
                  emit(Either.Right(local.getEpisodes().map { it.toEpisode() }))
              }
          }.catch {
              emit(Either.Left(Failure.CustomError(ServiceKOs.DATABASE_ACCESS_ERROR, "DB Error")))
          }.flowOn(Dispatchers.IO)
  
  
      private fun getRemoteEpisode(): Either&lt;Failure, List&lt;Episode&gt;&gt; =
          when (networkHandler.isConnected) {
              true -&gt; request(
                  service.getEpisodes(),
                  { episodeEntity -&gt;
  
                      val episodeList: List&lt;EpisodeEntity&gt; = episodeEntity.episodes
  
                      preferences.saveLong(LocalShared.LastAnimes.lastepisodes, Date().time)
  
                      addAllEpisodes(episodeList)
                      episodeList.map { it.toEpisode() }
  
                  },
                  EpisodesEntity(emptyList())
              )
              false, null -&gt; Either.Left(Failure.NetworkConnection())
          }
  
      private fun addAllEpisodes(episodes: List&lt;EpisodeEntity&gt;) {
          for (episode in episodes) {
              local.addEpisodes(episode)
          }
      }
  
  }
  </code></pre>
  
  <p>Room are the calls that are made from the local variable, the application checks if there is downloaded data and if there is not, it calls the service, returns the data and at the same time saves it in the Room database.</p>