package com.example.utility; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import com.alibaba.fastjson.JSONObject; import jakarta.servlet.http.HttpServletRequest; public class HttpGetJson { public static JSONObject getJson(HttpServletRequest request) { String result = ""; BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader( request.getInputStream(), "utf-8")); String line; while ((line = in.readLine()) != null) { result += line; } } catch (IOException e) { System.out.println(e.getMessage()); } finally { try { in.close(); } catch (IOException e) { System.out.println(e.getMessage()); } } return (JSONObject) JSONObject.parse(result); } } //参考文章:https://blog.csdn.net/weixin_56175092/article/details/126346904