gpt4 book ai didi

java - HttpsURLConnection 到 JSONObject 转换

转载 作者:行者123 更新时间:2023-12-01 09:42:06 24 4
gpt4 key购买 nike

try {         

url = new URL(https_url);
HttpsURLConnection posts = (HttpsURLConnection)url.openConnection();

} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

如何将 HttpsURLConnection posts 对象转换为 JSONObject?提前致谢。 :)

Answer: using the mvn org.json

最佳答案

  1. 寻找一个 JSON 库(有几十个,从 GSON、Jackson 等花哨的东西到更轻量级的)。
  2. 阅读其文档。
  3. 直接传递InputStream、将其包装在读取器中或将其作为字符串读取,具体取决于 API。

关于java - HttpsURLConnection 到 JSONObject 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38373224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com