-1

I've this call

@Headers("Content-Type: application/json")
@GET("/allMovies/allMovies.txt")
Call<List<Movies>> getAllMovies();

and this json

{
movies: [
{
id: "1000",
name: "Suicide Squad",
year: "2016",
category: "action",
},]}

with this model:

public class Movies {

private String id;
private String name;
private  String year;
private String category;

why am i getting

Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

Michael
  • 583
  • 4
  • 13
  • I am not getting it: Your JSON has one object, not an array. Additionally, it is invalid, as the keys are not double-quoted. – Seelenvirtuose May 27 '20 at 09:06
  • i've more ```{ id: "1000", name: "Suicide Squad", year: "2016", category: "action", }``` it's a list of this – Michael May 27 '20 at 09:09

1 Answers1

1

If you look at the response of the request, you'll notice that it doesn't return just a list of movies but an object that has a list of movies inside. So, basically, you need to create a class like this:

class MoviesListResponse {
    private List<Movie> movies;
}

and use it as a return type of your request.

Stanislav Shamilov
  • 1,746
  • 11
  • 20