阿比地址: http://suggest.taobao.com/sug?area=etao&code=utf-8&callback=KISSY.Suggest.callback&q=iphoneJSON返回格式
回報:
KISSY.Suggest.callback({"result": [["iphone4s", "9809"], ["iphone5", "13312"], ["iphone4 手機", "69494400"], ["iphone5 港行", "14267"], ["iphone5三網", "2271160"], ["iphone4手機殼", "6199679"], ["iphone 5手機殼", "2527284"], ["iphone 5 保護殼", "5727586"], ["iphone 4貼膜", "147271"], ["iphone5殼", "2628540"]]})
NSURL * url = [NSURL URLWithString:@"http://suggest.taobao.com/sug?area=etao&code=utf-8&callback=KISSY.Suggest.callback&q=iphone"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSHTTPURLResponse* urlResponse = nil;
NSError * error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
NSData *date = [NSData alloc]init
SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
// NSMutableArray *array=[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];
NSMutableArray *array = [jsonParser objectWithData:responseData];
NSLog(@"%@",array);
這個數組爲空。我不知道原因。
刪除「&回調= KISSY.Suggest.callback」我害怕它是與你的編碼和那些日本人?字符。 – Ares 2013-03-28 05:40:06
沒什麼可擔心的日語,它可以解析,請參考下面的答案。只需按照說明操作即可通過。 – 2013-03-28 06:52:59
謝謝你,但字符串是中國 – paul 2013-03-28 07:53:42