gpt4 book ai didi

iphone - 如何使用 SBJSON iPhone 处理 JSON 响应?

转载 作者:行者123 更新时间:2023-12-03 20:56:11 25 4
gpt4 key购买 nike

我从我的网络服务收到以下响应?任何人都可以知道如何使用 SBJSON 处理它吗?

{
"match_details" :
{
"score" : 86-1
"over" : 1.1
"runrate" : 73.71
"team_name" : England
"short_name" : ENG
"extra_run" : 50
}

"players" :
{
"key_0" :
{
"is_out" : 2
"runs" : 4
"balls" : 2
"four" : 1
"six" : 0
"batsman_name" : Ajmal Shahzad *
"wicket_info" : not out
}

"key_1" :
{
"is_out" : 1
"runs" : 12
"balls" : 6
"four" : 2
"six" : 0
"batsman_name" : Andrew Strauss
"wicket_info" : c. Kevin b.Kevin
}

"key_2" :
{
"is_out" : 2
"runs" : 20
"balls" : 7
"four" : 4
"six" : 0
"batsman_name" : Chris Tremlett *
"wicket_info" : not out
}

}

"fow" :
{
"0" : 40-1
}

}

我做了这样的事情:

最佳答案

导入SBJSON/JSON.h头文件并执行类似的操作...

NSString *jsonResponseString = ...your JSON response...;

NSDictionary *jsonDictionary = [jsonResponseString JSONValue];

NSDictionary *players = [jsonDictionary objectForKey:@"players"];

NSDictionary *player = [players objectForKey:@"key_0"];

NSLog( @"%@ %@ %@ %@ %@ %@ %@", [player objectForKey:@"is_out"],
[player objectForKey:@"runs"], [player objectForKey:@"balls"],
[player objectForKey:@"four"], [player objectForKey:@"six"],
[player objectForKey:@"batsman_name"], [player objectForKey:@"wicket_info"] );

...等等

关于iphone - 如何使用 SBJSON iPhone 处理 JSON 响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5118704/

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