【问题标题】:Send a NSMutableArray to Json server in PHP在 PHP 中将 NSMutableArray 发送到 Json 服务器
【发布时间】:2011-09-15 00:23:04
【问题描述】:

我有一个 NSmutableArray,我想以 JSON 格式发送到服务器,服务器会反序列化它并升级 mysql。

NSMutableArray * jsonObject = [[NSMutableArray alloc]initWithObjects:@"Some",nil];
NSString* jsonString = jsonObject.JSONRepresentation;

我认为这是正确的想法? 以及如何发送到服务器?

【问题讨论】:

    标签: php objective-c ios json nsmutablearray


    【解决方案1】:

    查看 NSMutableURLRequest 的 setHTTPMethod: (@"POST") 和 setHTTPBody: 方法。您可以构建请求并通过 NSURLConnection 发送。

    NSMutableURLRequest class reference

    NSURLConnection class reference

    【讨论】:

    • 是的,搜索带有 URL 请求的“POST”示例。大多数 Web 服务不接收 JSON 格式的数据,而是以该格式返回。您以 POST 正文格式向大多数 http 服务器发送数据,该格式看起来像格式难看的 URL 数据 name=John&foo=bar&…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多