@PostMapping(value = “/test”)
public JSONObject Test(InputStream inputStream) {
JSONObject json=new JSONObject();
String result = “”;
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();
result = new String(outSteam.toByteArray(), "UTF-8");
// System.out.println(result);
result = org.apache.commons.lang3.StringEscapeUtils.unescapeJava(result);//去转义符 斜杠
String newStr = result.substring(1, result.length()-1);//去除头和尾引号
System.out.printf(newStr);
JSONObject jsonObject=JSONObject.fromObject(newStr);
System.out.println(“jsonObject:”+jsonObject);
System.out.println(jsonObject);
} catch (Exception e) {
e.printStackTrace();
}
json.put(“result”, result);
return json;
}
亲测有效