无法从START_ARRAY中反序列化java.lang.String的实例

时间:2013-10-17 09:23:08

标签: java android json resttemplate

@JsonIgnoreProperties(ignoreUnknown = true)
public class TestResult {
private Map<String, String> datas;
>
......}

当我按如下方式使用RestTemplate时,我收到错误消息为标题

TestResult result= restTemplate.postForObject(AppConstants.URL +Secure/View/getTest",request, TestResult.class);

当我使用jmeter时,尝试获取数据是正确的,但在android上的falue(使用RestTemplate) 请帮我解决一下,谢谢!

10-17 17:08:27.571: E//RequestProcessor.java:250(16865): 17:08:27.570 pool-12-thread-1 An exception occured during request network execution :Could not read JSON: Can not deserialize instance   of java.lang.String out of START_ARRAY token
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):  at [Source: libcore.net.http.ChunkedInputStream@41b46428; line: 1, column: 11] (through reference chain: model.vo.TestResult["datas"]); nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):  at [Source: libcore.net.http.ChunkedInputStream@41b46428; line: 1, column: 11] (through reference chain: model.vo.TestResult["datas"])
10-17 17:08:27.571: E//RequestProcessor.java:250(16865): org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.lang.String out of START_ARRAY token
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):  at [Source: libcore.net.http.ChunkedInputStream@41b46428; line: 1, column: 11] (through reference chain: model.vo.TestResult["datas"]); nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):  at [Source: libcore.net.http.ChunkedInputStream@41b46428; line: 1, column: 11] (through reference chain: model.vo.TestResult["datas"])
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:125)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:147)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:76)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:484)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:317)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at service.TestRequest.loadDataFromNetwork(TestRequest.java:73)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at service.TestRequest.loadDataFromNetwork(TestRequest.java:1)
10-17 17:08:27.571: E//RequestProcessor.java:250(16865):    at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:27)

1 个答案:

答案 0 :(得分:0)

检查原始响应,尝试在浏览器或休息客户端中点击该网址以查看返回的内容。

  

无法读取JSON:无法从START_ARRAY标记中反序列化java.lang.String的实例

     

无法从START_ARRAY标记中反序列化java.lang.String的实例   chain:model.vo.TestResult [&#34; datas&#34;])

很难确定只有这么多信息。看起来json响应包含一个数组对象,但java bean字段是一个字符串。