在使用Gson解析JSON時出現異常。Gson(Json)解析異常
以下是例外:
com.google.gson.JsonParseException: The JsonDeserializer StringTypeAdapter failed to deserialize json object {"CGLIB$BOUND":true,"CGLIB$CONSTRUCTED":true,"CGLIB$CALLBACK_0":{"interfaces":[{}],"constructed":true,"persistentClass":{},"getIdentifierMethod":{"clazz":{},"slot":0,"name":"getmId","returnType":{},"parameterTypes":[],"exceptionTypes":[],"modifiers":1,"annotations":[0,3,0,67,0,0,0,68,0,0,0,69,0,1,0,70,115,0,71],"root":{"clazz":{},"slot":0,"name":"getmId","returnType":{},"parameterTypes":[],"exceptionTypes":[],"modifiers":1,"annotations":[0,3,0,67,0,0,0,68,0,0,0,69,0,1,0,70,115,0,71],"override":false},"override":false},"setIdentifierMethod":{"clazz":{},"slot":1,"name":"setmId","returnType":{},"parameterTypes":[{}],"exceptionTypes":[],"modifiers":1,"root":{"clazz":{},"slot":1,"name":"setmId","returnType":{},"parameterTypes":[{}],"exceptionTypes":[],"modifiers":1,"override":false},"override":false},"overridesEquals":false,"initialized":false,"entityName":"com.domain.Hotel","id":1,"unwrap":false},"mId":0,"mHotelLatitude":0.0,"mHotelLongitude":0.0,"mHotelRating":0.0,"mHotelAvgPrice":0.0} given the type class java.lang.String
JSON:
{
"CGLIB$BOUND": true,
"CGLIB$CONSTRUCTED": true,
"CGLIB$CALLBACK_0": {
"interfaces": [
{}
],
"constructed": true,
"persistentClass": {},
"getIdentifierMethod": {
"clazz": {},
"slot": 0,
"name": "getmId",
"returnType": {},
"parameterTypes": [],
"exceptionTypes": [],
"modifiers": 1,
"annotations": [
0,
3,
0,
67,
0,
0,
0,
68,
0,
0,
0,
69,
0,
1,
0,
70,
115,
0,
71
],
"root": {
"clazz": {},
"slot": 0,
"name": "getmId",
"returnType": {},
"parameterTypes": [],
"exceptionTypes": [],
"modifiers": 1,
"annotations": [
0,
3,
0,
67,
0,
0,
0,
68,
0,
0,
0,
69,
0,
1,
0,
70,
115,
0,
71
],
"override": false
},
"override": false
},
"setIdentifierMethod": {
"clazz": {},
"slot": 1,
"name": "setmId",
"returnType": {},
"parameterTypes": [
{}
],
"exceptionTypes": [],
"modifiers": 1,
"root": {
"clazz": {},
"slot": 1,
"name": "setmId",
"returnType": {},
"parameterTypes": [
{}
],
"exceptionTypes": [],
"modifiers": 1,
"override": false
},
"override": false
},
"overridesEquals": false,
"initialized": false,
"entityName": "com.domain.Hotel",
"id": 1,
"unwrap": false
},
"mId": 0,
"mHotelLatitude": 0,
"mHotelLongitude": 0,
"mHotelRating": 0,
"mHotelAvgPrice": 0
}
有誰知道爲什麼這個異常會來的想法?
問候
什麼是你解析的JSON,以及你想要反序列化到什麼類型?你用什麼代碼來做到這一點? –