The conversion process: first input stream into String type, re-use of json alibaba conversion tool string into the array json
SensorDevices sensorDevices = new SensorDevices(); request.setCharacterEncoding("utf-8"); JSONObject json = new JSONObject(); JSONArray list = new JSONArray(); BufferedReader br; String line = null; String brStr = null; String jsonStr = null; String jsonStr2 = null; try { br = new BufferedReader(new InputStreamReader((ServletInputStream) request.getInputStream())); StringBuilder sb = new StringBuilder(); // line = br.readLine(); while ((line = br.readLine()) != null) { sb.append(line); brStr = sb.toString(); } list = JSONArray.parseArray(brStr); } catch (IOException e) { e.printStackTrace(); } // System.out.println("+++++++++这是brStr:" + brStr); // System.out.println ( "+++++++++ This is JSON:" + json); // iterate json array System.out.println ( "+++++++++ This is JSONArray: "+ list);