Tag: jsonp

如何在Objective-C中parsingJSONP?

我正在检索一个API的JSON信息,它说在API中,它是在JSON中,但我注意到它是在JSONP或“有填充的JSON”,有些人称之为。 我厌倦了四处寻找如何parsing这个,但没有运气。 我想收到的信息是这样的: ({"book":[{"book_name":"James","book_nr":"59","chapter_nr":"3","chapter": {"16":{"verse_nr":"16","verse":"For where envying and strife is, there is confusion and every evil work."}}}],"direction":"LTR","type":"verse"}); 数据的链接是https://getbible.net/json?p=James3:16 ,所以你可以直接看它。 这是我正在使用的代码尝试检索JSON数据并将其parsing为一个NSMutableDictionary。 -(void)fetchJson { NSString *currentURL = [NSString stringWithFormat:@"https://getbible.net/json?p=James"]; NSURL *url = [NSURL URLWithString:currentURL]; NSData *data = [[NSData alloc]initWithContentsOfURL:url]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; NSMutableData *receivedData = [[NSMutableData alloc] initWithLength:0]; NSURLConnection * connection = [[NSURLConnection […]