繁体   English   中英

创建 JSONObject 实例时出现问题

[英]A problem when creating an instance of JSONObject

我是 java 的新手,我见过很多人像这样使用 JSONObject:

 String content ="....";
 JSONObject Object1 = new JSONObject(content);

但是当我这样做时,似乎:在此处输入图像描述

怎么了,请帮帮我。(我有“import net.sf.json.JSONObject”)

您提供的JSONObject来自流行的org.json库,其中包含与您的示例类似的构造函数

所以只需切换到这个库。

看起来,您正在导入错误的库。 您正在使用的库没有仅接收字符串参数的构造函数 boolean:

http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/JSONObject.html#JSONObject(boolean)

您在初始化JSONObject的新实例时尝试使用的库来自 Google:

https://developer.android.com/reference/org/json/JSONObject#JSONObject(java.lang.String)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM