解析Json數據web
1 //加載.json文件 2 NSString *path = [[NSBundle mainBundle]pathForResource:@"product.json" ofType:nil]; 3 //根據路徑加載json文件到nsdata中 4 NSData *data = [NSData dataWithContentsOfFile:(path)]; 5 //將加載進來的nsdata數據轉換爲OC中對應的對象 6 [NSJSONSerialization JSONObjectWithData:(NSData *) options:(NSJSONReadingOptions) error:(NSError *__autoreleasing *)];
UIWebViewjson
1 [webView loadRequest:NSURLRequest *]