【发布时间】:2014-01-02 07:44:43
【问题描述】:
我有很多 json 对象,例如:
{"id":"1","list":"456","name":"a"}, {"id":"2","list":"456","name":"b"}, {"id":"3","list":"456","name":"c"}
他们存储在NSDictionarydic1、dic2、dic3,然后我用NSArray存储这些dics,
这是我的问题,我如何发布这些词典?
我知道发布一个 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) {
}
那么,问题是 __jsonData 应该是什么?
【问题讨论】:
-
请看下面的答案。这与您想要的非常相似。 stackoverflow.com/questions/10290767/…
-
我有一个使用 xml 标签结构的解决方案,但我无法在答案中显示它,所以请使用这种方式试试这个格式
1 - as
charan 这里为2 - as
charan 运行一个循环,并将变量分配给 id、name 和 list在这里有一个带有信息列表的 xml 结构2 - as
charan