title: JsonArray to Kotlin data class using Retrofit and GsonConverterFactory(Expected BEGIN_OBJECT but was BEGIN_ARRAY)
body: <p>I'm trying to load quotesJson file from github(<a href="https://github.com/JamesFT/Database-Quotes-JSON/blob/master/quotes.json" rel="nofollow noreferrer">https://github.com/JamesFT/Database-Quotes-JSON/blob/master/quotes.json</a>). I'm new to retrofit and all of this, so I just tried following and understanding a tutorial(<a href="https://android.jlelse.eu/android-networking-in-2019-retrofit-with-kotlins-coroutines-aefe82c4d777" rel="nofollow noreferrer">https://android.jlelse.eu/android-networking-in-2019-retrofit-with-kotlins-coroutines-aefe82c4d777</a>) . Incredibly sorry if this is stupid or really easy. I'm still struggling with this. If i can get a short explanation of why it's done some other way I'd appreciate it!</p>
  
  <p>I've looked at documentation for Retrofit, searched all of the similar overflow questions. The problem is, if I try to change 
  <code>fun getQuotes(): Deferred&lt;Response&lt;QuoteResponse&gt;&gt;</code>
  to 
  <code>fun getQuotes(): Deferred&lt;ResponseList&lt;Quotes&gt;&gt;</code> 
  I get an error in 
  <code>val quoteResponse = safeApiCall(...</code></p>
  
  <pre><code>    private val okHttpClient = OkHttpClient().newBuilder()
          .build()
  
      fun retrofit() : Retrofit = Retrofit.Builder()
          .client(okHttpClient)
          .baseUrl("https://raw.githubusercontent.com/JamesFT/Database-Quotes-JSON/master/")
          .addConverterFactory(GsonConverterFactory.create())
          .addCallAdapterFactory(CoroutineCallAdapterFactory())
          .build()
  
  
      val quoteApi : QuoteApi = retrofit().create(QuoteApi::class.java)
  
  }
  </code></pre>
  
  <p>model </p>
  
  <pre><code>   val quoteAuthor : String,
     val quoteText : String
  )
  
  // Data Model for the Response returned from the Api
  data class QuoteResponse(
      val results : List&lt;Quote&gt;
  )
  
  //A retrofit Network Interface for the Api
  interface QuoteApi{
      @GET("quotes.json")
      fun getQuotes(): Deferred&lt;Response&lt;QuoteResponse&gt;&gt;
      // fun getQuotes(): Deferred&lt;Response&lt;QuoteResponse&gt;&gt;
  }
  </code></pre>
  
  <pre><code>val quoteResponse = safeApiCall(
              call = {api.getQuotes().await()}, // i get the error here if i change something myself
              errorMessage = "Error Fetching Popular Movies"
          )
  
          return quoteResponse?.results?.toMutableList()
  
      }
  </code></pre>
  
  <pre><code>suspend fun &lt;T : Any&gt; safeApiCall(call: suspend () -&gt; Response&lt;T&gt;, errorMessage: String): T? {
  
          val result : Result&lt;T&gt; = safeApiResult(call,errorMessage)
          var data : T? = null
  
          when(result) {
              is Result.Success -&gt;
                  data = result.data
              is Result.Error -&gt; {
                  Log.d("1.DataRepository", "$errorMessage &amp; Exception - ${result.exception}")
              }
          }
  
  
          return data
  
      }
  </code></pre>
  
  <pre><code>    Process: com.example.quoteappmvvm, PID: 7373
      com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
  ...
  
  Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
          at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
          at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)```
  </code></pre>