Reputation: 4717
my array returns the following valid json.
{"usernames ":["a","b","c"]}
In Java I am trying to retrieve the value of the array by the following method. However I fail.
JSONArray usernames = json.getJSONArray("usernames");
Upvotes: 2
Views: 189
Reputation: 631
The key ends with a space. try
JSONArray usernames = json.getJSONArray("usernames ");
EDIT: It would be better to lose the space in your php script.
Upvotes: 8