我得到 JSON 结果为-JSONValue failed. Error is: Unexpected end of input
. 请以正确的方式指导我。
我是解析新手。我必须通过 POST 方法从服务器获取数据。我有以下细节。我必须通过 url 传递 zip
{"zip":"52435","methodIdentifier":"search_dealer"}
url : http://usaautoleads.com/api.php
method: post
web service name: search_dealer
response : {"success":"0","dealer":[info...]}
我的代码在这里。
NSURL *myURL=[NSURL URLWithString:@"http://usaautoleads.com/api.php"];
NSString *post =[[NSString alloc]initWithString:@"52435"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[request setURL:myURL];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
[request setValue:@"application/json" forHTTPHeaderField:@"content-type"];
[[NSURLConnection alloc] initWithRequest:request delegate:self];