- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人可以帮我解决这个问题吗...
我只是想让这些代码行起作用。在 menuitemArray.length().getJSONObject(i)
处,它给了我错误,"cannot invoke getjsonobject(int) on the primitive type int"
代码如下:
private void parse(TextView txtResult) throws Exception{
jObject = new JSONObject(xResult);
JSONArray menuitemArray = jObject.getJSONArray("message");
String sret = "";
for (int i = 0; i < menuitemArray.length(); i++){
sret +=menuitemArray.length().getJSONObject(i).getString("username") + " : ";
System.out.println(menuitemArray.getJSONObject(i)
.getString("username"));
System.out.println(menuitemArray.getJSONObject(i)
.getString("subject"));
sret +=menuitemArray.getJSONObject(i)
.getString("subject") + "\n";
}
txtResult.setText(sret);
}
是的,我对此有点陌生。任何帮助将不胜感激。
最佳答案
改变
sret +=menuitemArray.length().getJSONObject(i).getString("username") + " : ";
到
sret +=menuitemArray.getJSONObject(i).getString("username") + " : ";
其实sret是一个字符串变量。你正试图从 menuitemArray 的长度中获取 username
。
关于android - 无法在原始类型 int 上调用 getjsonobject(int),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27222290/
我正在使用返回 JSON 的 REST Web 服务。但 JSON 对象值为 "[12]" 当我打印时。该值必须仅为 12,不含 "[]" 我的代码有问题吗?这是我的代码: HttpClient h
我正在尝试用我的 jsonArray 中的信息填充一个适配器。我在很多示例中都看到过这样做,但我收到错误消息“JSONObject 类型的方法 getJSONObject(String) 不适用于参数
我正在尝试解析一些 JSON。这是代码。 frc-manual.usfirst.org/a/GetAllItems/ManualID=3我已经尝试了几个小时让它工作,但我在网上看到的每个示例都使用 g
有人可以指导我吗?我正在尝试将一些对象解析到我的 JSONArray 中。但是我的 JSON 文件有点复杂。我正在尝试获取标题、描述和缩略图 我的 JSON 文件 { "query": {
我正在使用 org.json库作为我的 Java 应用程序的 JSON 客户端,我想知道这个库中一些方法的复杂性。 我正在通过它的 HTTP API 从数据库中检索另一个 JSON 对象(等等)内的
我正在尝试使用以下方法从 JSON 文件中获取一些值: JSONParser parser = new JSONParser(); Object obj = parser.parse(new File
在 json 对象中,如果我们可以通过 jsonobj.has("element_name") 找到数据是否存在,我们如何检查数据是 jsonarray 还是 json 对象,如果只找到一个事件元素并
我已经包含了所有库,包括 jason-simple-1.1.1.jar、org.json.20120521.jar。我仍然面临这个错误: getJSONObject(String) is undefi
我正在从我的类(class)返回一个 json: @POST("/test") @PermitAll public JSONObject test(Map form) { JS
有人可以帮我解决这个问题吗... 我只是想让这些代码行起作用。在 menuitemArray.length().getJSONObject(i) 处,它给了我错误,"cannot invoke get
我对应用程序的性能有疑问。 我在外部数据库中有一个对象,我已经从数据库中提取了所有关于它的数据,包括唯一 ID。我开始了一项新 Activity ,但我想在新 Activity 中对同一对象使用相同的
我正在处理深度嵌套的 JSON 数据。这是一个简短的示例: { "timestamp":"123", "layers":{ "frame_raw":"123",
我想浏览下面的 json 文件并保存“坐标”后面的部分。 json 文件: {"type": "FeatureCollection","features": [{"type": "Feature","
我目前正在开发一个 Android 应用程序,用于显示以 JSON 序列化的对象。它在我的 Nexus 5 (4.4.2) 上运行良好,但在 Samsung Galaxy S3 (4.3) 上崩溃。应
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我是一名优秀的程序员,十分优秀!