Json GSON正在尝试将字符串反序列化为double
我正在使用GSON转换器进行改装,以从RESTful Web服务获取JSON,当GSON尝试将JSON对象转换为POJO时,我得到了错误: Converter:conversionException:com.google.gson.JsonSyntaxException:java.lang.NumberFormatException:无效双精度:“610/182” 此元素对应于我的Java对象中的字符串变量:Json GSON正在尝试将字符串反序列化为double,json,string,double,gson,retrofit,Json,String,Double,Gson,Retrofit,我正在使用GSON转换器进行改装,以从RESTful Web服务获取JSON,当GSON尝试将JSON对象转换为POJO时,我得到了错误: Converter:conversionException:com.google.gson.JsonSyntaxException:java.lang.NumberFormatException:无效双精度:“610/182” 此元素对应于我的Java对象中的字符串变量: @Expose @SerializedName("code") private Str
@Expose
@SerializedName("code")
private String code;
...
JSON对象是:
{“code”:“610/182”,…}
我在我的重新适应程序中添加了一个转换器,如下所示:
restAdapter = new RestAdapter.Builder()
.setEndpoint(URL_BASE)
.setClient(new OkClient(getClient()))
.setConverter(new GsonConverter(gson))
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
api = restAdapter.create(ApiRest.class);
为什么GSON试图将字符串转换为双精度?您能否发布转换的完整代码。其他问题在其他地方有语法错误,导致这种情况。比如说完成课程后。确保没有其他`@SerializedName(“代码”)`已修复此问题此错误的原因是什么?