转载地址:http://blog.csdn.net/wfung_kwok/article/details/7042101
- <SPAN style="WHITE-SPACE: pre"> </SPAN>request.setCharacterEncoding("UTF-8");
- response.setContentType("text/html;charset=UTF-8");
- String acceptjson ="";
- try {
- BufferedReader br =new BufferedReader(new InputStreamReader(
- (ServletInputStream) request.getInputStream(),"utf-8"));
- StringBuffer sb =new StringBuffer("");
- String temp;
- while ((temp = br.readLine()) !=null) {
- sb.append(temp);
- }
- br.close();
- acceptjson = sb.toString();
- if (acceptjson !="") {
- JSONObject jo = JSONObject.fromObject(acceptjson);
- JSONArray imgArray = jo.getJSONArray("PartsImages");
- JSONArray infArray = jo.getJSONArray("BasicInfo");
- for (int i =0; i < imgArray.size(); i++) {
- JSONObject imgObject = JSONObject.fromObject(imgArray
- .get(i));
- System.out.println(imgObject.get("PartsImg"));
- }
- JSONObject infObject = JSONObject.fromObject(infArray.get(0));
- System.out.println(infObject.get("Parts_cate"));
- System.out.println(infObject.get("Company"));
- System.out.println(infObject.get("Parts_name"));
- System.out.println(infObject.get("TEL"));
- System.out.println(infObject.get("Parts_price"));
- System.out.println(infObject.get("Suitable"));
- System.out.println(infObject.get("UsedStyle"));
- System.out.println(infObject.get("Supplement"));
- System.out.println(jo.toString());
- }
- response.getWriter().write(MyReadFile.read("/post/publishsuccess"));
- } catch (Exception e) {
- e.printStackTrace();
- response.getWriter().write(MyReadFile.read("/post/publishfailure"));
- }
- ======================================================
- {
- "PartsImages": [
- {
- "PartsImg": "PNG Data"
- },
- {
- "PartsImg": "PNG Data"
- },
- {
- "PartsImg": "PNG Data"
- },
- {
- "PartsImg": "PNG Data"
- }
- ],
- "BasicInfo": [
- {
- "Parts_cate": "避震",
- "Company": "極品(Acura)",
- "Parts_name": "AFTC",
- "TEL": "62341456",
- "Parts_price": "6000",
- "Suitable": "0",
- "UsedStyle": "全新",
- "Supplement": "極品,全新,九折"
- }
- ]
- }