【问题标题】:how to retrieve Json arrray [closed]如何检索 Json 数组
【发布时间】:2014-04-17 19:25:13
【问题描述】:

我试图从这个 json 中检索 lat,lng 值,但没有人帮我检索它。

提前致谢。

{
    response: {
        Success: "1",
        lat: [
            "2",
            "3"
        ],
        lon: [
            "2",
            "3"
        ]
    }
}

【问题讨论】:

  • 另外,这不是一个有效的 json
  • 我通过以下操作检索了值 ArrayList lat=new ArrayList(); ArrayList lng=new ArrayList(); jasonparser jp = 新的 jasonparser(); j = jp.getJSONFromUrl(url); JSONObject jobj = j.getJSONObject("response");字符串成功=jobj.getString("成功"); if(success.equals("1")) { JSONArray 结果 = jobj.getJSONArray("lat"); for (int i = 0; i

标签: android json arrays


【解决方案1】:
 JSONObject jsonResponse = new JSONObject(yourString);
 JSONArray latitude= jsonResponse.getJSONArray("lat");

for (int i=0; i<latitude.length(); i++) {
    JSONObject lat= latitude.getJSONObject(i);
}

【讨论】:

  • 感谢您的回复
猜你喜欢
  • 2019-03-16
  • 2011-02-14
  • 1970-01-01
  • 1970-01-01
  • 2020-06-20
  • 2020-10-21
  • 2010-11-30
  • 2016-10-31
  • 1970-01-01
相关资源
最近更新 更多