我的数组返回以下有效的 json。
{"usernames ":["a","b","c"]}
在 Java 中,我试图通过以下方法检索数组的值。但是我失败了。
JSONArray usernames = json.getJSONArray("usernames");
最佳答案
键以空格结尾。尝试
JSONArray usernames = json.getJSONArray("usernames ");
编辑: 最好在您的 php 脚本中丢失空间。
关于java - 无法从 php 解析 json 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16420362/