I know this is not the first time someone asking about this problem but with Retrofit2 I can't find the right solution to my problem.
I have an object that contains a list of String. when I want to convert JSON response to my object all other fields are ok but I got this error for converting the list of string to my list:
Retrofit2: Expected BEGIN_ARRAY but was STRING at line 1 column 268 path $[0].images
This is my API:
@POST("/cp/api/")// get list of products
Call<List<Product>> Get_Special_Products(@Body Object request);
My Retrofit setting:
public Retrofit Store_retrofit(OkHttpClient client) {
return new Retrofit.Builder()
.baseUrl(Urls.Sotre_Base_Url)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
My Object:
public class Product implements Serializable {
@SerializedName("id")
private int id;
@SerializedName("user_id")
private int user_id;
@SerializedName("cat_id")
private int cat_id;
@SerializedName("title")
private String title;
@SerializedName("description")
private String description;
@SerializedName("image")
private String image;
@SerializedName("images")
private List<String> images;
public int getUser_id() {
return user_id;
}
public int getCat_id() {
return cat_id;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String getImage() {
return image;
}
public List<String> getImages() {
return images;
}
}
and this a part of JSON that cause the error for image:
images:[
"1487801544.jpg","1487801544.jpg","1487801544.jpg"
]