2011-04-28 233 views
0

我正在發送JSON PUT請求。我正在使用JSONKIT。我不確定如何將字典轉換爲JSON數據?json PUT請求

我想在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"]; 

回答