Ios iPhone如何使用json发布nsarry

Ios iPhone如何使用json发布nsarry,ios,iphone,json,post,ios5,Ios,Iphone,Json,Post,Ios5,我有很多json对象,比如: {"id":"1","list":"456","name":"a"}, {"id":"2","list":"456","name":"b"}, {"id":"3","list":"456","name":"c"} 它们存储在NSDictionarydic1、dic2、dic3中,然后我使用NSArray存储这些dic 这是我的问题,我如何发布这些词典 我知道PostOne json对象,下面是我的代码 NSString *url = [SERVERPREFIX s

我有很多json对象,比如:

{"id":"1","list":"456","name":"a"}, {"id":"2","list":"456","name":"b"}, {"id":"3","list":"456","name":"c"}
它们存储在
NSDictionary
dic1、dic2、dic3中,然后我使用
NSArray
存储这些dic

这是我的问题,我如何发布这些词典

我知道PostOne json对象,下面是我的代码

NSString *url = [SERVERPREFIX stringByAppendingString:urlString];
DLog(@"url:%@", url);
NSURL *reqURL = [NSURL URLWithString:url];
NSData ***__jsonData**;
// Be sure to properly escape your url string.
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:reqURL];
[request setHTTPMethod:@"POST"];
[request setHTTPBody: **__jsonData**];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

[request setValue:[NSString stringWithFormat:@"%d", (unsigned int)[__jsonData length]] forHTTPHeaderField:@"Content-Length"];


[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
}


因此,问题是\uu jsonData应该是什么?

jsonData应该是:

jsonData = [NSJSONSerialization dataWithJSONObject:yourNSArray options:NSJSONWritingPrettyPrinted error:&error];
试试这个 将数组转换为json

NSString *sendingData = [yourarray JSONRepresentation];

请看下面的答案。这与您想要的非常相似。我有一个使用xml标记结构的解决方案,但我无法在回答中显示它,因此请使用这种方式尝试此格式1作为字符2作为字符在这里运行循环2作为字符,并将变量分配给id、名称和列表,因此这里将有一个xml结构和信息列表