Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 杰克逊';s在Gson中的JsonNode实现_Android_Serialization_Jackson_Gson - Fatal编程技术网

Android 杰克逊';s在Gson中的JsonNode实现

Android 杰克逊';s在Gson中的JsonNode实现,android,serialization,jackson,gson,Android,Serialization,Jackson,Gson,由于dex的大小,我目前正在将Jackson实现转换为Gson 我想知道Gson的等价物是什么 public void setNortheast(JsonNode northeast) { LatLng northBound = new LatLng(northeast.get("lat").asDouble(), northeast.get("lng").asDouble()); this.northeast = northBound; } 我

由于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;
}
但是,它似乎不起作用。我是否编写了正确的代码


提前谢谢!:我认为应该使用getDouble而不是Double.parseDouble(“字符串”)

东北方向。getDouble(“lat”)

东北双(“液化天然气”)

修改代码如下:

public void setNortheast(JsonObject northeast) {
    LatLng northBound = null;
    try {
        northBound = new LatLng(northeast.getDouble("lat"), northeast.getDouble("lng"));
    } catch(JsonException e) {
    }
    this.northeast = northBound;
}

参考资料:

你得到了什么?您是否确认参数
JsonObject
设置正确?