我正在使用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)