gpt4 book ai didi

android - 改造解析字符串数组

转载 作者:行者123 更新时间:2023-11-29 14:46:47 24 4
gpt4 key购买 nike

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

最佳答案

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

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

同步调用看起来像

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

关于android - 改造解析字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33220003/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com