这是我解析 json 服务的代码。但是我在 json 字典中得到了 nil 值。但是当我复制 json 响应并制作一个 .txt 文件并解析它时。它运作良好。奇怪的问题。
-(void)viewDidLoad
{
[super viewDidLoad];
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:@"http://www.checker.co.il/testing/c_pda-load_reports_list.php?app=1"];
[self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
});
}
- (void)fetchedData:(NSData *)responseData {
//parse out the json data
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData //1
options:kNilOptions
error:&error];
}
这种类型的反应,我得到了。
{"204281":{"rpID":"204281","ReportTitle":"Main Performance
Analysis","ReportOrder":"2","URL":"report-network-status.php?ClientID=106&BranchID=&SetID=&
PropID=&props=&reportDateArng=3&hdrf_chosenCycleExtent=7&rangeStartd=0&rangeStartm=0&
rangeStarty=0&rangeEndd=0&rangeEndm=0&rangeEndy=0&pastDateCyclesNumber=2&selectedCycleExtent=&
showClientColorGroup=1&displayType=3&DyChartType=Bar2D&DycX=400&DycY=350&isPopup=0&
callingReportPageName=report-network-status.php&ReportTitle=\"%20
\"","ReportCategory":"Performance","CategoryRow":"0","CategoryCol":"4"},"204282":
{"rpID":"204282","ReportTitle":"Performance According to
Ownership","ReportOrder":"5","URL":"report-property.php?ClientID=106&SetID=&PropID=78&
PropForFiltering=&props=&WorkerID=0&watchedReviews=&reportDateArng=1&hdrf_chosenCycleExtent=&
rangeStartd=0&rangeStartm=0&rangeStarty=0&rangeEndd=0&rangeEndm=0&rangeEndy=0&
pastDateCyclesNumber=2&selectedCycleExtent=&displayType=3&DyChartType=Column2D&DycX=400&DycY=250&
callingReportPageName=report-property.php&js_refresh=0&js_submit=0&
isPopup=0","ReportCategory":"Performance","CategoryRow":"0","CategoryCol":"4"}}
提前致谢。:)