static String jsonStr = "{"sites":[{"name":"gold","url":"www.baidu.com"},{"name":"jlong","url":"http://baidu.com/"}]}";
public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
// 将json字符串转为jsonbject
JSONObject jsonStrObject = jsonObject.parseObject(jsonStr);
JSONArray jsonArray = jsonStrObject.getJSONArray("sites");
for (Object object : jsonArray) {
JSONObject stObject = (JSONObject) object;
String name = stObject.getString("name");
String url = stObject.getString("url");
System.out.println(name + "---" + url);
}
}