我试图只获取可以存储到 ArrayList 或 Array 的 JSONArray 的值。我的代码目前是这样的:
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++;
}
我的问题是我也拿到了钥匙:
ChatterName: Steve
ChatterName: Blubb
ChatterName: 2
ChatterName: 3
ChatterName: Joey
ChatterName: 4
ChatterName: Chris
这是 JSON 的样子:
Input Stream(Response vom Server): {"statuscode":"200","sequence":1382,"response":"sendWho","params":["1","Steve","Blubb","2","3","Joey","4","Chris"]}