gpt4 book ai didi

ios - ios中如何解析多个json?

转载 作者:行者123 更新时间:2023-11-29 12:53:19 26 4
gpt4 key购买 nike

我有一个问题。我必须解析这个 json:

{
"category_id" = 1;
fullname = "Wiadomo\U015bci";
name = wiadomosci;
"page_index" = 0;
"show_live" = 1;
},
{
"category_id" = 2;
fullname = Kultura;
name = kultura;
"page_index" = 1;
"show_live" = 0;
},
{
"category_id" = 3;
fullname = Rozrywka;
name = rozrywka;
"page_index" = 2;
"show_live" = 0;
},
{
"category_id" = 4;
fullname = Biznes;
name = biznes;
"page_index" = 3;
"show_live" = 0;
}

我有两个数组,其中包含 category_id、全名、名称和 page_index。怎么办?

我使用了 AFnetworking:

self.manager = [AFHTTPRequestOperationManager manager];
[self.manager setRequestSerializer:[AFHTTPRequestSerializer serializer]];
self.manager.responseSerializer = [AFJSONResponseSerializer serializer];
[self.manager GET:@"http://webapi.test.pl/newsCategoriesForMobileApp/iphone" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];

而且我不知道如何解析 json。

最佳答案

你已经有了字典数组,你只需要执行以下操作

for(NSDictionary *dic in jsonArray){

NSLog(@"%@, %@, %@",[dic objectForKey:@"category_id"],[dic objectForKey:@"fullname"],[dic objectForKey:@"page_index"]);

}

关于ios - ios中如何解析多个json?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21878757/

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