解析没有key的Json

 

没有key的Json,例如:["http://www.cnblogs.com/Cherry-B/p/4625133.html","http://www.cnblogs.com/Cherry-B/p/4619689.html","http://www.cnblogs.com/Cherry-B/p/4613701.html"]

  public void alyJson(String urls) {
    ArrayList<String> urlList = null;
    if (urls != null) {
      try {
        JSONArray array = new JSONArray(urls);
        urlList = new ArrayList<String>();
        for (int i = 0; i < array.length(); i++) {
          String s = array.getString(i);
          urlList.add(s);
        }
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }

    if (urlList != null) {
      for (String url : urlList) {
        webView.loadUrl(url);
      }
    }
  }

 

posted @ 2015-07-08 17:19  Pepper.B  阅读(2115)  评论(0编辑  收藏  举报