用JSON-Simple做的,结果是一个二为阵列,至於输出格式,这个你可以自己修正。
Java codepublicstaticvoidmain(String[] args){
String s="[{\"type\":\"城际高速\",\"station\":\"北京南\",\"stationNO\":\"1\",\"days\":\"1\",\"arriveTime\":\"-\",\"startDriveTime\":\"08:45\",\"km\":\"0\"},{\"type\":\"城际高速\",\"station\":\"天津\",\"stationNO\":\"2\",\"days\":\"1\",\"arriveTime\":\"09:15\",\"startDriveTime\":\"-\",\"km\":\"120\"}]";
Object obj=JSONValue.parse(s);
JSONArray array=(JSONArray)obj;
Iterator iter=array.iterator();
String[][] ary=newString[array.size()+1][7];
String[] ss={"type","station","stationNO","days","arriveTime","startDriveTime","km"};int[] a={1,2,3};
ary[0]=ss;inti=1;while(iter.hasNext()){
JSONObject jObj=(JSONObject)iter.next();
ary[i]=newString[7];
ary[i][0]=(String)jObj.get("type");
ary[i][1]=(String)jObj.get("station");
ary[i][2]=(String)jObj.get("stationNO");
ary[i][3]=(String)jObj.get("days");
ary[i][4]=(String)jObj.get("arriveTime");
ary[i][5]=(String)jObj.get("startDriveTime");
ary[i][6]=(String)jObj.get("km");
i++;
}
System.out.println(Arrays.toString(ary[0]));
System.out.println(Arrays.toString(ary[1]));
System.out.println(Arrays.toString(ary[2]));
}
温馨提示:答案为网友推荐,仅供参考