JSONでデータを抽出してUITableViewに入れる必要がありますが、抽出しようとするとこのエラーが発生します。
-JSONValue failed. Error is: Illegal start of token [E]
サイト内のデータは多く、100,000 を超えています。おそらく多すぎますか? 私のコード:
#import <UIKit/UIKit.h>
#import "SBJson.h"
@interface ProductsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, NSURLConnectionDataDelegate> {
NSURLConnection *conn;
NSMutableData *webData;
}
ProductsViewController.m 内
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url=[NSURL URLWithString:@"http://www.e-xxxxxxx.it/virtualShop/pageflow/address/xxxxxxxxxxxx.do?json=true&vsIdxxxxxxxxxxxxxxxxxxxxxxxxxx=Ext.data.JsonP.callback1"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
conn =[[NSURLConnection alloc]initWithRequest:req delegate:self];
if(conn){
webData =[[NSMutableData alloc]init];
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
[webData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"Connection failed: %@", [error description]);
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSLog(@" the number of data is %d", [webData length]);
//the number of data is 104557
NSString *strResult =[[NSString alloc]initWithData:webData encoding:NSUTF8StringEncoding];
NSDictionary *result =[strResult JSONValue];//the error is here
for (id obj in result){
NSLog(@"%@", result);
}
}
文字列strResultは非常に長く、これは一部です
Ext.data.JsonP.callback1(
{ "urlId": "spesa-che-non-pesa-root",
"children" :
[{ "urlId": "9950000123511",
"label" : "I dolci della Pasqua" ,
"hasWideIcon" : false ,
"hasArticles" :false,
"children" : [{ "urlId": "9950000123512",
"label" : "Colombe" ,
"hasWideIcon" : false ,
"hasArticles" :false,
"children" : [{ "urlId": "9950000123513",
"label" : "Tradizionali" ,
"hasWideIcon" : false ,
"hasArticles" :true},
{ "urlId": "9950000123514",
"label" : "Farcite e ricoperte" ,
"hasWideIcon" : false ,
"hasArticles" :true},
{ "urlId": "9950000123515",
"label" : "Piccole" ,
"hasWideIcon" : false ,
"hasArticles" :true}]},
{ "urlId": "9950000123516",
"label" : "Torte " ,
"hasWideIcon" : false ,
"hasArticles" :true},
{ "urlId": "9950000123517",
"label" : "Uova al latte" ,
"hasWideIcon" : false ,
"hasArticles" :true},
{ "urlId": "9950000123522",
"label" : "Cioccolatini e Dolciumi" ,
"hasWideIcon" : false ,
"hasArticles" :true}]}