Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的数组返回以下有效的 json。
{"usernames ":["a","b","c"]}
在 Java 中,我试图通过以下方法检索数组的值。然而我失败了。
JSONArray usernames = json.getJSONArray("usernames");
键以空格结尾。尝试
JSONArray usernames = json.getJSONArray("usernames ");
编辑:最好丢失 php 脚本中的空间。
删除代码中的空格:"usernames " --->"usernames"
"usernames "
"usernames"