I'm trying to get just the values of a JSONArray that i can store to a ArrayList or an Array. My Code is this at the moment:
JSONArray params = (JSONArray) res.get("params");
for (int j = 1; j <= params.size(); j++){
Object chatter = params.get(j);
String chatterName = chatter.toString();
System.out.println("ChatterName: "+chatterName);
int index = 2;
listModel.add(index, chatterName);
index++;
}
My problem is that i get the keys too:
ChatterName: Steve
ChatterName: Blubb
ChatterName: 2
ChatterName: 3
ChatterName: Joey
ChatterName: 4
ChatterName: Chris
This is the JSON looks like:
Input Stream(Response vom Server): {"statuscode":"200","sequence":1382,"response":"sendWho","params":["1","Steve","Blubb","2","3","Joey","4","Chris"]}
Ok, I solved the problem. It wasn't a "json-simple" issue, but a logical one. I'm building a server-client chat application and before entering a name, which I'm asked for by the server, I put an id as a key to the client. But I forgot to delete this key and because of this I get the keys too.