Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                                                                                            
                
        
我从webservice的json回复就像
 在Android中为{"d":"[{\"userid\":507}]"}。我需要从此响应中获取用户ID。这怎么可能?

最佳答案

尝试这种方式

private void parseJson(String response) {
        try{
            JSONObject main = new JSONObject(response);
            JSONArray d = main.getJSONArray("d");

            for (int i = 0; i <d.length(); i++) {
                JSONObject item = d.getJSONObject(i);
                System.out.println("userid : " + item.getString("userid"));
            }
        }catch (Exception e) {
        }
    }

07-24 09:39