3

我尝试从 json 数组中获取数据

String username = object.getJSONObject("items").getString("f");

但这给了我一个错误

"items.f" not found. 

下面是 Json 数组。

{
    "items": [
       {
           "s": "0",
           "f": "monems",
           "m": "ustad"
       },
       {
           "s": "0",
           "f": "monems",
           "m": "There?"
       },                      
       {
           "s": "0",
           "f": "monems",
           "m": "What's going on ?"
       },                      
       {
           "s": "2",
           "f": "monems",
           "m": "Sent at 4:03AM May 20th"
       }        
    ]
}
4

1 回答 1

1

尝试这个 -

JSONArray items=object.getJSONArray("items");
for(int i=1;i<=items.length();i++){
    JSONObject jsonObj=items.getJSONObject(i); 
    String s=jsonObj.getString("f");

}
于 2013-05-20T12:55:48.847 回答