如何将json数据发布到webservice

时间:2013-06-26 08:20:57

标签: objective-c json web-services

我有一个包含一些属性的json字符串。

看起来像这样的json:

2013-06-26 14:59:06.363 DesignTable[1772:c07] {
  "Table" : {
    "Table name" : "F",
    "Number of Seats" : "4",
    "tableLocation" : {
      "y coordinate" : "141.00",
      "x coordinate" : "347.50"
    }
  }
}
2013-06-26 14:59:06.363 DesignTable[1772:c07] {
  "Table" : {
    "Table name" : "G",
    "Number of Seats" : "4",
    "tableLocation" : {
      "y coordinate" : "255.50",
      "x coordinate" : "360.50"
    }
  }
}

如何将此帖子发布到webservice并将其发布到数据库?

2 个答案:

答案 0 :(得分:0)

如果您不仅仅是谈论json而是谈论休息,那么请看看RestKit:http://restkit.org/ 这里有一个很好的教程: http://www.raywenderlich.com/13097/intro-to-restkit-tutorial

答案 1 :(得分:0)

你可以使用ASIHTTP ......

    NSURL *url = [NSURL URLWithString:BASE_URL];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    request.tag = 666;
    request.delegate = self;
    request.timeOutSeconds = 200;
    [request setRequestMethod:@"POST"];


    [request setPostValue:@"YourData" forKey:@"your_key"];

    [request startAsynchronous];

这可能对你有所帮助....