Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 改型-JsonSyntaxException尝试获取response.body时_Java_Android_Android Studio_Retrofit_Retrofit2 - Fatal编程技术网

Java 改型-JsonSyntaxException尝试获取response.body时

Java 改型-JsonSyntaxException尝试获取response.body时,java,android,android-studio,retrofit,retrofit2,Java,Android,Android Studio,Retrofit,Retrofit2,所以我试图从我的服务器获取response.body,这是GpsCordinates类型的列表 从服务器上我得到如下响应: [ { "x": 33333, "y": 333, "date": 1516532556000 }, { "x": 3, "y": 4, "date": 1516542914000 } ] 请求: @GET("....") Call<List<GpsCordinates>> getGPSCordinatesForDay(); 当我尝试时

所以我试图从我的服务器获取response.body,这是GpsCordinates类型的列表

从服务器上我得到如下响应:

[
{
"x": 33333,
"y": 333,
"date": 1516532556000
},
{
"x": 3,
"y": 4,
"date": 1516542914000
}
]
请求:

@GET("....")
    Call<List<GpsCordinates>> getGPSCordinatesForDay(); 
当我尝试时,我得到:
D/ERROR:com.google.gson.JsonSyntaxException:1516532556000

使用long而不是
日期
。您的服务器发送时间戳(毫秒)。

在我的服务器中,日期也是java.util.date类型
Api api = Api.RetrofitInstance.create();
    api.getGPSCordinatesForDay().enqueue(new Callback<List<GpsCordinates>>() {
        @Override
        public void onResponse(Call<List<GpsCordinates>> call, Response<List<GpsCordinates>> response) {
            if (response.isSuccessful()) {
                List<GpsCordinates> gpsCordinates = response.body();
            }
        }
        @Override
        public void onFailure(Call<List<GpsCordinates>> call, Throwable t) {
            Log.d("ERROR", t.toString());
        }
    });
 @SerializedName("x")
@Expose
private double x;
@SerializedName("y")
@Expose
private double y;
@SerializedName("date")
@Expose
private Date date;

public double getX() {
    return x;
}

public void setX(double x) {
    this.x = x;
}

public double getY() {
    return y;
}

public void setY(double y) {
    this.y = y;
}

public Date getDate() {
    return date;
}

public void setDate(Date date) {
    this.date = date;
}