JSONArray如何遍歷

String a = "[1,2]";
        JSONArray json = JSONArray.fromObject(a);


        if(json.size()>0){
            Object[] objects =  json.toArray();
            for(int i=0;i<objects.length;i++){
                int j = (int) objects[i];
                System.out.println(objects[i]) ;
                System.out.println("j=="+j);// 得到 每個對象中的屬性值
            }
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章