小编Nou*_*ine的帖子

尝试在json中解析日期/时间时出现com.google.gson.JsonSyntaxException

我正在使用RestTemplete从rest api获取json数据,而我正在使用Gson将数据从json格式解析为Object

Gson gson = new Gson();

restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

List<Appel> resultList = null;

resultList = Arrays.asList(restTemplate.getForObject(urlService, Appel[].class));
Run Code Online (Sandbox Code Playgroud)

但我用Date来解决这个问题,我该怎么办..

Could not read JSON: 1382828400000; nested exception is com.google.gson.JsonSyntaxException: 1382828400000
Run Code Online (Sandbox Code Playgroud)

我的Pojo包含其他pojos的身体

public class Appel implements Serializable {

    private Integer numOrdre;
    private String reference;
    private String objet;
    private String organisme;
    private Double budget;
    private Double caution;
    private Date dateParution;
    private Date heureParution;
    private Date dateLimite;
    private Date heureLimite;
    private List<Support> supportList;
    private Ville villeid;
    private Categorie categorieid; …
Run Code Online (Sandbox Code Playgroud)

java android json gson

14
推荐指数
2
解决办法
3万
查看次数

标签 统计

android ×1

gson ×1

java ×1

json ×1