在我的应用程序中,我想使用Retrofit从服务器获取一些数据。
我写了下面的代码,但是当运行应用程序并调用 api 时显示以下错误:
E/socketLogResponse: Err : com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
请查看我上面的代码并帮助我
来自服务器的 API 响应:
{
"status": "ok",
"time": 0.014972925186157227
}
ApiService 接口:
@POST("api/log")
Call<SocketPingResponse> getSocketPingLog(@Header("jwt") String jwt, @Body SocketPingBodySendData socketPingBodySendData);
SocketPingResponse 类:
public class SocketPingResponse {
@SerializedName("status")
@Expose
private String status;
@SerializedName("time")
@Expose
private Double time;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getTime() {
return time;
}
public void setTime(Double time) {
this.time = time;
}
}
SocketPingBodySendData 类:
public class SocketPingBodySendData {
@SerializedName("auction_id")
@Expose
int auction_id;
@SerializedName("data")
@Expose
List<SocketPingEntity> data;
public int getAuction_id() {
return auction_id;
}
public void setAuction_id(int auction_id) {
this.auction_id = auction_id;
}
public List<SocketPingEntity> getData() {
return data;
}
public void setData(List<SocketPingEntity> data) {
this.data = data;
}
}
扬帆大鱼
动漫人物
拉风的咖菲猫
相关分类