改造解析字符串数组

Retrofit parse array of strings

我在使用改造解析服务器响应时遇到了问题。服务器 returns 字符串数组,如何解析这个:["1", "21", "22"] 使用改造框架。我正在使用 Retrofit 2.0.0-beta2。 谢谢

要解析该响应,请像这样在 API 接口中定义您的方法:

@GET("methodThatReturnsArray")
Call<ArrayList<String>> methodThatReturnsArray();

同步调用看起来像

Call<ArrayList<String>> call = retrofitService.methodThatReturnsArray();
Response response = call.execute();
ArrayList<String> arrayOfStrings = response.body();