gpt4 book ai didi

java - 无法导入 org.json.simple.JSONObject 出现错误,提示 "org.jason cannot be resolved"

转载 作者:太空宇宙 更新时间:2023-11-04 14:30:30 26 4
gpt4 key购买 nike

我正在尝试编写一个程序,该程序读取 Web 服务并使用 JSONObject 对象对其进行表述。我正在使用 Eclipse

当我尝试导入库 org.json.simple.JSONObject 时;我收到一条错误消息“org.jason 无法解析”

代码 list

import java.net.URL;

import org.json.simple.JSONObject;

//错误信息“导入“org.json 无法解析”

import java.io.*;
import javax.net.ssl.HttpsURLConnection; // This is where I get the error message

public class cStart {

cGraphData ReadData;

public static void main (String[] args) {

System.out.println("Welcome to the world of Java Programming.");
String reply="";
cGraphData ReadData= new cGraphData();
try {
String httpsURL = "https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC";
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
InputStream ins = con.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);

String inputLine;


while ((inputLine = in.readLine()) != null)
{
reply+=inputLine;
}
} catch (Exception e)
{
System.out.println("Exception in getting data from server");
}
System.out.println(reply);
JSONObject t;


}

}

最佳答案

只需将 gradle 或 maven 依赖项添加到您的项目中对于梯度:

compile group: 'org.json', name: 'json', version: '20180130'

对于行家

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>

关于java - 无法导入 org.json.simple.JSONObject 出现错误,提示 "org.jason cannot be resolved",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26224914/

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