改造解析字符串数组

时间:2015-10-19 17:02:04

标签: android retrofit

我在使用改造解析服务器响应方面遇到了麻烦。服务器返回字符串数组,如何解析它:[" 1"," 21"," 22"]使用改进框架。我使用的是Retrofit 2.0.0-beta2。 感谢

1 个答案:

答案 0 :(得分:6)

要解析该响应,请在API界面中定义您的方法,如下所示:

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

同步通话看起来像

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