0

I'm new with Moshi and I'm trying to parse the data, with Retrofit, from one class that extends an Arraylist of items and I'm getting this error:

  com.squareup.moshi.JsonDataException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $

Class:

class CarSelection: ArrayList<CarItem>()

data class CarItem(
    @field:Json(name = "type") val type: String,
    @field:Json(name = "name") val name: String,
    @field:Json(name = "color") val color: String,
    @field:Json(name = "image") val image: String
)

Retrofit service:

 fun getRemoteService(baseUrl :String, client : OkHttpClient): MyRemoteService {
            return Retrofit.Builder()
                .baseUrl(baseUrl)
                .client(client)
                .addConverterFactory(MoshiConverterFactory.create())
                .build()
                .create(MyRemoteService::class.java)
        }
halfer
  • 19,824
  • 17
  • 99
  • 186
S.P.
  • 2,274
  • 4
  • 26
  • 57

0 Answers0