新浪微博api 用户标签获取 java

try {

jsonArray = net.sf.json.JSONArray.fromObject("返回的html");

int iSize = jsonArray.size();

System.out.println("Size:" + iSize);

PingByUrlDao pbd;

for (int i = 0; i < iSize; i++) {

net.sf.json.JSONObject jsonObj = jsonArray.getJSONObject(i);

//System.out.println("[" + i + "]UID=" + jsonObj.get("id"));

//System.out.println("[" + i + "]LABLE=" + jsonObj.get("tags"));

 

net.sf.json.JSONArray jsonArray2=net.sf.json.JSONArray.fromObject(jsonObj.get("tags")+"");

System.out.println("标签数量:"+jsonArray2.size());

String biglable="";

pbd=new PingByUrlDao();

for (int j = 0; j < jsonArray2.size(); j++) {

net.sf.json.JSONObject jsonObj2 = jsonArray2.getJSONObject(j);

 

Map map = (Map)jsonObj2;

Set<String> key = map.keySet();

for (Iterator it = key.iterator(); it.hasNext();) {

String s = (String) it.next();

//            Map map2 = (Map) map.get(s);

//System.out.println("键名========================"+s);

//System.out.println("标签========================"+jsonObj2.get(s));

biglable+=jsonObj2.get(s)+",";

break;

}

//System.out.println("======================================================="+j);

}

if (biglable.indexOf(",")!=-1) {

biglable=biglable.substring(0, biglable.lastIndexOf(","));

}

pbd.setLab(biglable);

mapBB.put(jsonObj.get("id")+"", pbd);

 

//System.out.println("UID:"+jsonObj.get("id"));

//System.out.println("标签:"+biglable);

}

return mapBB;

} catch (net.sf.json.JSONException e) {

System.out.println("json解析错误:"+e);

e.printStackTrace();

}

 

http://blog.csdn.net/macwhirr123/article/details/8940351

你可能感兴趣的:(java)