1.Java解析raw请求的json格式数据
private JSONObject readRaw(InputStream inputStream){
JSONObject json = null;
try{
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) != -1) {
outSteam.write(buffer, 0, len);
}
outSteam.close();
inputStream.close();
String result = new String(outSteam.toByteArray(), "UTF-8");
json = (JSONObject) JSONObject.parse(result);
}catch (Exception e){
e.printStackTrace();
logger.info(e.toString());
}
return json;
}