0
我正在解析json並且url正在返回一個整數值。 (例如278)JSON int格式的數據
-(void) connectionDidFinishLoading: (NSURLConnection *) connection{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSString *responseString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"JSON Response = %@",responseString);}
當我在打印響應的NSLog
,它給出了這樣的事情
2012-09-15 18:02:02.091 Web Service[5190:f803] JSON Response = "278"
我不想在引號輸出。我希望它喜歡
2012-09-15 18:02:02.091 Web Service[5190:f803] JSON Response = 278
我怎樣才能做到這一點?
JSON提前
NSString *urlString = [NSString stringWithFormat:@"http://10.5.6.105/ARAPPWS/Service1/InsertEmp/name=%@,phone=%@",name.text,number.text];
NSURL *addUrl = [NSURL URLWithString:urlString];
NSURLRequest *addRequest = [NSURLRequest requestWithURL:addUrl];
(void)[NSURLConnection connectionWithRequest:addRequest delegate:self];
-(void) connection: (NSURLConnection *) connection didReceiveResponse:(NSURLResponse *)response
{
jsonData = [[NSMutableData alloc]init];
}
-(void) connection: (NSURLConnection *) connection didReceiveData:(NSData *)data
{
[jsonData appendData:data];
}
-(void) connectionDidFinishLoading: (NSURLConnection *) connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
responseString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[self performSelector:@selector(uploadEmpImg:) withObject:nil afterDelay:1];
}
感謝。
它給我JSON響應= 0而不是JSON響應= 278 –
@Ankur所以web服務返回'278'或'「278」'?順便說一下,爲什麼不使用適當的JSON解析器而不是黑客? – 2012-09-15 12:59:51
我的web服務返回278. 我是新來的JSON解析我不知道如何使用正確的JSON。 –