作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我有这条线:
JSONObject res = new JSONObject(result);
这个的输出是:
{
"result": "[\"Pretty Woman\",\"Minions Banana Song\",\"Squatters Rights\",\"Minions Banana\",\"Minions Puppy\"]",
"id": 0,
"jsonrpc": "2.0"
}
然后我有一行:
JSONArray moviesJson = res.optJSONArray("result");
并且其输出为空。这是我的语法错误吗?我不知道发生了什么。
我试图将结果中包含的数组作为我的输出
最佳答案
键 result
包含一个数组,但以单个字符串的形式。您可以获得数组:
JSONArray moviesJson = new JSONArray(res.getString("result"));
关于java - 为 optJSONArray 取空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46538507/
所以我有这条线: JSONObject res = new JSONObject(result); 这个的输出是: { "result": "[\"Pretty Woman\",\"Minions
我是一名优秀的程序员,十分优秀!