JSONObject和JSONArray的数据表示形式
JSONObject的数据是用 { } 来表示的,
例如: { “id” : “123”, “courseID” : “huangt-test”, “title” : “提交作业”, “content” : null } 就像某个对象一样他有四个属性,分别有不同的值,
而JSONArray,顾名思义是由JSONObject构成的数组,用 [ { } , { } , … , { } ] 来表示
例如: [ { “id” : “123”, “courseID” : “huangt-test”, “title” : “提交作业” } , { “content” : null, “beginTime” : 1398873600000 “endTime” } ] ;就是有很多对象,将这些对象用[ ]括起来就形成了jsonarray
[ { “id” : “123”, “courseID” : “huangt-test”, “title” : “提交作业” } , { “content” : null, “beginTime” : 1398873600000 “endTime” } ]
怎么去解析jsonarray呢?????
for(int i=0;i<jsonArray.length;i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);//将的到的array转换成jsonobject
String idvalue=jsonObject.getString(“id”);
}