如何从网址获取JSON并将NSString
编码为使用NSLog
显示?
JSON包含中文单词。
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://jxdp.mnks.cn/read.php?xCode=6beff&Code=6beff&Type=1&&top=5&min=0&CALL="]];
[request setHTTPMethod:@"GET"];
NSURLResponse *requestResponse;
NSData *requestHandler = [NSURLConnection sendSynchronousRequest:request returningResponse:&requestResponse error:nil];
NSString *requestReply = [[NSString alloc] initWithBytes:[requestHandler bytes] length:[requestHandler length] encoding:NSUTF8StringEncoding];
NSLog(@"requestReply: %@", requestReply);