developerWab 2013-01-07 02:47 采纳率: 0%
浏览 4376
已采纳

IOS添加json文件的条目计数

大家好,我创建了一个json请求:

for (int i=0; i<= [urls count]-1; i++) {
    self.items=[[NSMutableDictionary alloc] init];
    [self.items setObject:[names objectAtIndex:i] forKey:@"results"];
    [self.items setObject:[urls objectAtIndex:i] forKey:@"URL"];
    [self.list addObject:_soccerList];
}

NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:_list
                                                   options:0
                                                     error:&error];

self.results=[NSJSONSerialization
                           JSONObjectWithData:jsonData
                           options:0
                           error:&error];

但是我需要添加这个标题到json请求中,其中添加条目计数。不知道如何实现?

{
"resultCount":50,
"results": [

/// json content 

]
}
  • 写回答

2条回答

  • abcdeFGh_xyz 2013-01-07 05:14
    关注

    for循环的adding _soccerList,在这行之前加下面的代码:

     NSDictionary *dic=[[NSDictionary alloc] initWithObjectsAndKeys:[self.items count],@"resultCount",nil];
     [self.list addObject:dic];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记