json PUT请求

时间:2011-04-28 05:46:18

标签: iphone json object

我正在发送JSON PUT请求。我正在使用JSONKIT。我不确定如何将字典转换为JSON数据?

我想在JSONKIT中使用JSONREPRESNTATION(JSON解析器)的等效方法。示例代码如下。

NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] initWithCapacity:0];

[jsonDict setObject:@"linkedin-html" forKey:@"contentType"];

  [jsonDict setObject:@"dfdfdf" forKey:@"body"];

  NSString *jsonRequest = [jsonDict JSONData];  // doubt line

  NSData *requestData = [NSData dataWithBytes:[jsonRequest UTF8String] length:[jsonRequest length]]; 

  [self setHTTPBody:requestData];

 [self setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];  

  [self setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

1 个答案:

答案 0 :(得分:0)

id json = [arrayOne JSONString];

可在https://github.com/johnezang/JSONKit/blob/master/README.md

获取