当前位置 : 主页 > 编程语言 > python >

[IOS] 用json-framework解析json数据

来源:互联网 收集:自由互联 发布时间:2023-03-22
下载json-framework[url]https://github.com/stig/json-framework/[/url] //http访问接口返回jsonNSMutableURLRequest* request = [[NSMutableURLRequest alloc] init];[request setURL:[NSURL URLWithString:@"http://iaiai.iteye.com"]];[request s

下载json-framework [url]https://github.com/stig/json-framework/[/url]

//http访问接口返回jsonNSMutableURLRequest* request = [[NSMutableURLRequest alloc] init];[request setURL:[NSURL URLWithString:@"http://iaiai.iteye.com"]];[request setHTTPMethod:method];NSHTTPURLResponse* urlResponse = nil;NSError *error = [[NSError alloc] init];NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];NSMutableString *result = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];//把json转成对象//NSDictionary* json = [result JSONValue];NSMutableArray* json = [result JSONValue];NSArray* list = [NSArray alloc];for (NSDictionary *dictionary in json){//对NSMutableArray进行遍历 NSLog(@"%@,%@",[dictionary objectForKey:@"appType"],[dictionary objectForKey:@"copyright"]);}
上一篇:[IOS] NSDictionary读取boolean值数据
下一篇:没有了
网友评论