내 iPhone 응용 프로그램에서 json 부분을이 URL에서 분할하려고합니다.응답이 아닌 URL에서 JSON을 분할하고 싶습니다.
http://vkontakte.ru/login_success.html#session={"expire":"1272008089","mid":"100172","secret":"9c8d8f0305","sid":"1131703552161ae352a1256402e3140d7cbde41b1602a93d15472c82 "}
내가 시도하고있는 NSString에 JSON을 저장하지만 내가 무엇입니까 것은
http://vkontakte.ru/api/login_success.html?session=%7B%22mid%22 : 113158415, % 22secret % 22 : % 227ce58bfcd3 % 22, % 22sid % 22 : % 2203831b43c1bb992f9477efbfe96e83f6ecff1c1b661315ac0a20719cf57a44 % 22, % 22expire % 22 : 0 % 7D
이것은 JSOn 형식으로 제공되지 않습니다. 아래는 내 코드입니다
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = [request URL];
NSError* error;
NSLog (@"json path %@",url);
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSURLRequest *request1 = [NSURLRequest requestWithURL:url];
NSString *json_string = [url absoluteString];
NSArray *arr = [json_string componentsSeparatedByString:@"="];
json_string = [arr objectAtIndex:1];
// parse the JSON response into an object
// Here we're using NSArray since we're parsing an array of JSON status objects
NSArray *statuses = [json_string JSONValue];
NSLog(@"%@",error);
// Each element in statuses is a single status
// represented as a NSDictionary
for (NSDictionary *status in statuses)
{
// You can retrieve individual values using objectForKey on the status NSDictionary
// This will print the tweet and username to the console
NSLog(@"%@ - %@", [status objectForKey:@"secret "], [[status objectForKey:@"mid"] objectForKey:@"sid"]);
}
return YES;
}
어떻게 더 멀리 이동할 수 있습니까? 교체
나는이 URL에 비밀 키를 제공하는 Vkontakte에서 공유를 시도하고 있습니다. – Pras
고마워요. 그것은 잘 작동합니다! – Pras