Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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 如何从json获取对象/_Android_Json - Fatal编程技术网

Android 如何从json获取对象/

Android 如何从json获取对象/,android,json,Android,Json,这是我的json数据,以及如何从json数据中获取纬度和经度 List<Double> lat = new ArrayList<>(); List<Double> lng = new ArrayList<>(); try { JSONObject jsonObject= new JSONObject(response); JSONArray jsonArray= jsonObject.getJS


这是我的json数据,以及如何从json数据中获取纬度和经度

  List<Double> lat = new ArrayList<>();
    List<Double> lng = new ArrayList<>();

    try {
        JSONObject jsonObject= new JSONObject(response);
        JSONArray jsonArray= jsonObject.getJSONArray("results");
        for(int i=0;i< jsonArray.length();i++)
        {
            lat.add(jsonArray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"));
            lng.add(jsonArray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

你试过什么?这只是一个例子。显示一些努力首先尝试使用pojo Classis进行解析我想将纬度和长度存储到一个从json数据获取的字符串是的,我们知道你想要什么,但是?@Denny使用这个lat和long,当我将这个lat和long放入另一个我想要的URL时,我想得到这个位置最近的位置。谢谢Hitesh Gehlot