通过URL建立连接 然后解析json

    xiaoxiao2021-03-26  13

    URL url = new URL(strUrl);             BufferedReader br = new BufferedReader(new InputStreamReader(url             .openStream(), "UTF-8"));             String s = "";             StringBuffer sb = new StringBuffer("");             while ((s = br.readLine()) != null) {                sb.append(s);

                }

    picObj = new JSONObject(homePicContent);

    String picData = picObj.getString("data");

    for(int i=0;i<picSize;i++){                 JSONObject picJsonObj = picjsonArray.getJSONObject(i);                 HomePicDto homePicDto = new HomePicDto();                 homePicDto.setPicPath(picJsonObj.get("picPath").toString());                 homePicDto.setLink(picJsonObj.get("link").toString());                 homePicDtoList.add(homePicDto);             }

    转载请注明原文地址: https://ju.6miu.com/read-450173.html

    最新回复(0)