【发布时间】:2022-01-21 23:03:39
【问题描述】:
我正在尝试使用 Retrofit 读取此 JSON,但出现此错误 Could not locate ResponseBody converter for class org.json.JSONObject.
ALE2 文件中的 JSON
{
"a1":[...],
"a2":[...],
"a3":[...]
}
代码
Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL).build();
retrofit.create(RetrofitInterface.class).getData().enqueue(new Callback < JSONObject > () {
@Override
public void onResponse(Call < JSONObject > call, Response < JSONObject > response) {
}
@Override
public void onFailure(Call < JSONObject > call, Throwable t) {
}
});
改造界面
public interface RetrofitInterface {
@GET("ALE2")
Call<JSONObject> getData();
}
我不想将它们存储在任何模型中,我只想将 JSON 作为字符串获取
【问题讨论】:
标签: android retrofit retrofit2