JSONObject 与 JSONArray 的使用
//遍历json数组
Stringjson1="{data:[{name:'Wallace'},{name:'Grommit'}]}";
jsonObjSplit=newJSONObject(json1);
JSONArrayja=jsonObjSplit.getJSONArray("data");
for(inti=0;i<ja.length();i++){
JSONObjectjo=(JSONObject)ja.get(i);
System.out.println(jo.get("name"));
}
//JSONObject遍历json对象
Stringjson2="{name:'Wallace',age:15}";
jsonObj=newJSONObject(json2);
for(Iteratoriter=jsonObj.keys();iter.hasNext();){
Stringkey=(String)iter.next();
System.out.println(jsonObj.getString(Key));
}
相关推荐
somebodyoneday 2020-06-15
83163452 2020-01-28
adonislu 2020-01-10
baijinswpu 2020-01-01
adonislu 2019-12-31
xufankang 2019-12-19
somebodyoneday 2019-12-07
somebodyoneday 2019-10-30
ZCMUCZX 2016-04-14
WebVincent 2020-07-21
fengchao000 2020-07-04
baijinswpu 2020-06-28
88483063 2020-06-28
fengchao000 2020-06-16
wujiajax 2020-06-14
somebodyoneday 2020-05-16
xx0cw 2020-05-16
newthon 2020-05-14