求解析下面这段JSON 红色是需要得到的值 急求!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!用了不少方法 可是总是有错 求简单有效的方法 最好是能够用代码来解释 表示不要只给思路 现在思路一大推
{
"RspMessage": {
"Body": {
"orderHeads": {
"com.qthd.deal.server.client.vo.OrderHead": [
{
"linkAddr": "成都市",
"orderDetails": {
"com.qthd.deal.server.client.vo.OrderDetail": [
{
"proId": "22",
"proName": "巴西咖啡豆",
"proType": "4",
"proCount": "100",
"salePrice": "16"
},
{
"proId": "102",
"proName": "意式浓缩(单孔)",
"proType": "1",
"proCount": "2",
"salePrice": "2000"
}
]
},
"LinkTel": "18981825090",
"orderNum": "SD2014120900000002",
"addDate": "2014-12-0910:51:41.0"
},
{
"linkAddr": "成都市",
"orderDetails": {
"com.qthd.deal.server.client.vo.OrderDetail": [
{
"proId": "22",
"proName": "巴西咖啡豆",
"proType": "4",
"proCount": "100",
"salePrice": "16"
},
{
"proId": "102",
"proName": "意式浓缩(单孔)",
"proType": "1",
"proCount": "2",
"salePrice": "2000"
}
]
},
"LinkTel": "18981825090",
"orderNum": "SD2014120900000001",
"addDate": "2014-12-0910:40:51.0"
}
]
}
},
"Head": {
"returnCode": "DEAL0000",
"returnMessage": "操作执行成功"
}
}
}
------解决思路----------------------
栗子:
{"calendar":
{"calendarlist":
[
{"calendar_id":"1705","title":"(\u4eb2\u5b50)ddssd","category_name":"\u9ed8\u8ba4\u5206\u7c7b","showtime":"1288927800","endshowtime":"1288931400","allDay":false},
{"calendar_id":"1706","title":"(\u65c5\u884c)","category_name":"\u9ed8\u8ba4\u5206\u7c7b","showtime":"1288933200","endshowtime":"1288936800","allDay":false}
]
}
}
JSON转换
JSONObject jsonObject = new JSONObject(builder.toString())
.getJSONObject("calendar");
JSONArray jsonArray = jsonObject.getJSONArray("calendarlist");
for(int i=0;i<jsonArray.length();i++){
JSONObject jsonObject2 = (JSONObject)jsonArray.opt(i);
CalendarInfo calendarInfo = new CalendarInfo();
calendarInfo.setCalendar_id(jsonObject2.getString("calendar_id"));
calendarInfo.setTitle(jsonObject2.getString("title"));
calendarInfo.setCategory_name(jsonObject2.getString("category_name"));
calendarInfo.setShowtime(jsonObject2.getString("showtime"));
calendarInfo.setEndtime(jsonObject2.getString("endshowtime"));
calendarInfo.setAllDay(jsonObject2.getBoolean("allDay"));
calendarInfos.add(calendarInfo);
}
------解决思路----------------------