由于dex大小,我目前正在将Jackson实现转换为Gson。
我想知道什么是Gson相当于
public void setNortheast(JsonNode northeast) {
LatLng northBound = new LatLng(northeast.get("lat").asDouble(), northeast.get("lng").asDouble());
this.northeast = northBound;
}
我写道:
public void setNortheast(JsonObject northeast) {
LatLng northBound = null;
try {
northBound = new LatLng(Double.parseDouble(northeast.getString("lat")), Double.parseDouble(northeast.getString("lng")));
} catch(JsonException e) {
}
this.northeast = northBound;
}
但是,它似乎不起作用。我写了正确的代码吗?
提前致谢! :d
答案 0 :(得分:0)
我认为你应该使用getDouble而不是Double.parseDouble(“String”)
northeast.getDouble( “LAT”)
northeast.getDouble( “LNG”)
修改后的代码如下,
public void setNortheast(JsonObject northeast) {
LatLng northBound = null;
try {
northBound = new LatLng(northeast.getDouble("lat"), northeast.getDouble("lng"));
} catch(JsonException e) {
}
this.northeast = northBound;
}