我在异步任务中有这个调用。所有参数都是正确的。在postman或advance rest客户端中,调用工作正常,并返回带有对象列表的json。但是,如果我尝试使用spring在android中执行此调用,则会出现此错误:
org.springframework.http.converter.HttpMessageNotReadableException:无法读取JSON:无法从START_OBJECT令牌中反序列化java.lang.String的实例 在[来源:org.apache.http.conn.EofSensorInputStream@1961b5e; line:1,column:1];嵌套异常是com.fasterxml.jackson.databind.JsonMappingException:无法从START_OBJECT标记中反序列化java.lang.String的实例 在[来源:org.apache.http.conn.EofSensorInputStream@1961b5e; line:1,column:1]
这是预期的json响应
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
这是我的AsyncTask
[
{
"id": 57,
"user_id": 2,
"category_id": 5,
"notification_title": "test 9",
"notification_body": "breve 9",
"description": "Sd sdfds sdfs dfsd fdsf",
"image": null,
"code": "2-5942525969dfa",
"start_date": null,
"expiration_date": null,
"created_at": "2017-06-15 09:24:41",
"updated_at": "2017-06-15 09:24:41"
},
{
"id": 56,
"user_id": 2,
"category_id": 4,
"notification_title": "test 8",
"notification_body": "breve desc 8",
"description": "Sdfsdf sdfds dsfs dsfds",
"image": null,
"code": "2-59424e24570a2",
"start_date": null,
"expiration_date": null,
"created_at": "2017-06-15 09:06:44",
"updated_at": "2017-06-15 09:06:44"
}]
有人能帮助我吗?
答案 0 :(得分:0)
问题解决了,spring框架休息的版本错了,我使用的是1.0.1 RELEASE但正确的版本是:
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'