java解析JSON 数组数据 实例
public static void main (String args[]){
String sJson ="[{'acceptTime':'2011-11-24 17:55:00','acceptAddress':'上海邮政速递物流长宁经营部','remark':'收寄'},"+
"{'acceptTime':'2011-11-24 17:59:00','acceptAddress':'上海邮政速递物流长宁经营部','remark':'离开处理中心,发往上海市邮政公司邮政速递局'},"+
"{'acceptTime':'2011-11-24 23:54:38','acceptAddress':'上海市','remark':'到达处理中心,来自上海邮政速递物流长宁经营部'},"+
"{'acceptTime':'2011-11-25 00:17:42','acceptAddress':'上海市','remark':'离开处理中心,发往USSFOF'},"+
"{'acceptTime':'2011-12-05 07:41:00','acceptAddress':'美国 94704','remark':'到达投递局'},"+
"{'acceptTime':'2011-12-05 11:07:00','acceptAddress':'美国 94703','remark':'妥投'}]";
JSONArray jsonArray;
try {
jsonArray = new JSONArray(sJson);
int iSize = jsonArray.length();
for (int i = 0; i < iSize; i++) {
JSONObject jsonObj = jsonArray.getJSONObject(i);
System.out.println( jsonObj.get("acceptTime")+","+jsonObj.get("acceptAddress")+","+jsonObj.get("remark"));
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
本文原创,转载必追究版权。