预期 BEGIN_ARRAY 但在第 1 行第 1 列路径 $ ....z 处为 STRING

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

为什么会出现这个错误?

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

io.reactivex.exceptions.OnErrorNotImplementedException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

public class RetrofitClient {
    private static Retrofit retrofit=null;
    private static Gson gson = new GsonBuilder()
            .setLenient()
            .create();
    public static Retrofit getClient(String baseUrl){
        if(retrofit == null){
            retrofit = new Retrofit.Builder()
                    .baseUrl(baseUrl)
                    .addConverterFactory(GsonConverterFactory.create(gson))
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();
        }
        return retrofit;
    }

public interface API {
@GET("getmenu.php")
Observable<List <MainMenu>> getMenu();
}

MainMenu.class :

public class MainMenu {
    public String ID;
    public String Name;
    public String Link;

}

您收到错误是因为 json 中的内容不符合 List <MainMenu> 模型。如果您想获得具体答案,post 您的 json 和 MainMenu 模型。