获取 NumberFormatException:无效的双精度:“”
Getting NumberFormatException: Invalid double: ""
将数据附加到我的 arrayList 时出现此错误。
这是我的 JsonResponse
[
{
"ChatId": 13,
"Name": [],
"LoginUserId": "123xc-xcv4r4",
"Message": [
{
"message": "Message 1 ",
"Status": 0,
"Date": "2017-09-11T12:56:21.07",
"Name": "name",
"UserId": "12",
"Id": 0,
"Latitude": "",
"Longitude": ""
},
],
"UserId": ["3434scjdcndne4r4ir" ]
}
]
我将上面的回复附加为
Type type = new TypeToken<List<jsonModel>>() {
}.getType();
arraylist= Conversions.getGson().fromJson(response, type);
我没有在我的代码中使用任何双精度值
错误出现在
arraylist= Conversions.getGson().fromJson(response, type);
om.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Invalid double: ""
W/System.err: at com.google.gson.internal.bind.TypeAdapters.read(TypeAdapters.java:323)
W/System.err: at com.google.gson.internal.bind.TypeAdapters.read(TypeAdapters.java:313)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.read(ReflectiveTypeAdapterFactory.java:129)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
W/System.err: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.read(ReflectiveTypeAdapterFactory.java:129)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
W/System.err: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory
这是我的pojoclass
private int ChatId;
private ArrayList<String> Name = new ArrayList<String>();
private String LoginUserId;
private ArrayList<AllUserMessages> Message = new
ArrayList<AllUserMessages>();
private ArrayList<String> UserId = new ArrayList<String>();
请帮我解决这个问题
1) 尝试将您的 AllUserMessages
class Latitude, Longitude
变量类型 double
更改为 String
2) 或将 Latitude, Longitude
从服务器站点更改为双站点。
将数据附加到我的 arrayList 时出现此错误。
这是我的 JsonResponse
[
{
"ChatId": 13,
"Name": [],
"LoginUserId": "123xc-xcv4r4",
"Message": [
{
"message": "Message 1 ",
"Status": 0,
"Date": "2017-09-11T12:56:21.07",
"Name": "name",
"UserId": "12",
"Id": 0,
"Latitude": "",
"Longitude": ""
},
],
"UserId": ["3434scjdcndne4r4ir" ]
}
]
我将上面的回复附加为
Type type = new TypeToken<List<jsonModel>>() {
}.getType();
arraylist= Conversions.getGson().fromJson(response, type);
我没有在我的代码中使用任何双精度值
错误出现在
arraylist= Conversions.getGson().fromJson(response, type);
om.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Invalid double: ""
W/System.err: at com.google.gson.internal.bind.TypeAdapters.read(TypeAdapters.java:323)
W/System.err: at com.google.gson.internal.bind.TypeAdapters.read(TypeAdapters.java:313)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.read(ReflectiveTypeAdapterFactory.java:129)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
W/System.err: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.read(ReflectiveTypeAdapterFactory.java:129)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
W/System.err: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory
这是我的pojoclass
private int ChatId;
private ArrayList<String> Name = new ArrayList<String>();
private String LoginUserId;
private ArrayList<AllUserMessages> Message = new
ArrayList<AllUserMessages>();
private ArrayList<String> UserId = new ArrayList<String>();
请帮我解决这个问题
1) 尝试将您的 AllUserMessages
class Latitude, Longitude
变量类型 double
更改为 String
2) 或将 Latitude, Longitude
从服务器站点更改为双站点。