方法:
Iterator iter = jsonInfo.entrySet().iterator();
代码示例:
public class Test { public static void main(String[] args) { JSONObject jsonInfo = new JSONObject(); String key1 = "a"; jsonInfo.put(key1, "aa"); String key2 = "b"; jsonInfo.put(key2, "bb"); Iterator iter = jsonInfo.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey().toString()); System.out.println(entry.getValue().toString()); } } }