gpt4 book ai didi

blackberry - Json 数组 - 黑莓

转载 作者:行者123 更新时间:2023-12-03 16:42:48 27 4
gpt4 key购买 nike

我尝试从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"
}
]
}

最佳答案

试试这个-

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

}

关于blackberry - Json 数组 - 黑莓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16645847/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com