ale*_*oid 0 json jackson resttemplate
我具有以下JSON属性:
"created_at":"2017-12-08T10:56:01.000Z"
Run Code Online (Sandbox Code Playgroud)
我想使用Jackson以下属性反序列化JSON文档:
@JsonProperty("created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-ddTHH:mm:ss.SSSZ")
private java.util.Date createdAt;
Run Code Online (Sandbox Code Playgroud)
但失败,但以下异常:
org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.example.domain.Product] and content type [application/json;charset=utf-8]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:119)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:986)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:969)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:717)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:671)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:587)
Run Code Online (Sandbox Code Playgroud)
我在做什么错以及如何解决?
问题出pattern在JsonFormat。
使用"yyyy-MM-dd'T'HH:mm:ss.SSSZ"代替"yyyy-MM-ddTHH:mm:ss.SSSZ"。
"yyyy-MM-dd'T'HH:mm:ss.SSSZ" 对于 "2017-12-08T13:50:07.811+0000"
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" 对于 "2017-12-08T13:49:42.128Z"
| 归档时间: |
|
| 查看次数: |
762 次 |
| 最近记录: |