Java JSONObject 无法解析为类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26439675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSONObject cannot be resolved to a type
提问by code511788465541441
I cannot import JSONObject, I thought this was something that came with java and an external jar is not needed, why is it saying it cannot find it?
我无法导入 JSONObject,我认为这是 java 附带的东西,不需要外部 jar,为什么说找不到它?
采纳答案by msrd0
I thought this was something that came with java and an external jar is not needed
我认为这是 Java 附带的东西,不需要外部 jar
No - JsonObject
is only in JavaEE. JSONObject
isn't included in JavaSE, it needs an external library. You can find it on github. However, if you use JavaEE, it is included.
否 -JsonObject
仅在 JavaEE 中。JSONObject
不包含在 JavaSE 中,它需要一个外部库。你可以在github上找到它。但是,如果您使用 JavaEE,则它包含在内。
If you are using gradle, add the following to your build.gradle
file (available in maven central):
如果您使用的是 gradle,请将以下内容添加到您的build.gradle
文件中(在maven central 中可用):
dependencies {
compile "org.json:json:20171018"
}
回答by EpicPandaForce
You need to use the following library in Java SE: https://jsonp.java.net/
您需要在 Java SE 中使用以下库:https: //jsonp.java.net/
The JSR 353: Java API for JSON Processing
is only in Java EE by default, not in Java SE.
在JSR 353: Java API for JSON Processing
仅在Java EE中默认情况下,不会在Java SE。