You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
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