Hallo Forum-Mitglieder,
ich versuche derzeit einen JSON auszuwerten. das JSON sieht folgender maßen aus.
Alles anzeigen
Den JSON frage ich in XCODE wie folgt ab:
Alles anzeigen
Ich komme mit der Abfrage bis zum Punkt movies. Ich möchte aber Beispielsweise title abfragen. Wenn ich dann die Zeile ändere in "NSLog(@"SID: %@", [[[json objectForKey:@"data"] objectForKey:@"movies"] objectForKey:@"title"]);" stürzt das Programm ab.
Hat vielleicht jemand Erfahrung mit JSON.
Mit freundlichen Grüssen
David
ich versuche derzeit einen JSON auszuwerten. das JSON sieht folgender maßen aus.
Quellcode
- [b] data = {[/b]
- [b] movies = ([/b]
- [b] {[/b]
- [b] additional = {[/b]
- [b] "watched_ratio" = 0;[/b]
- [b] };[/b]
- [b] certificate = "";[/b]
- [b] id = 5;[/b]
- [b] "last_watched" = 0;[/b]
- [b] "mapper_id" = 9;[/b]
- [b] "metadata_locked" = 0;[/b]
- [b] "original_available" = "2008-09-25";[/b]
- [b] "sort_title" = "Test";[/b]
- [b] title = "Test";[/b]
- [b] },[/b]
Den JSON frage ich in XCODE wie folgt ab:
Quellcode
- NSString *urlString = [NSString stringWithFormat:@"http://%@:%@/webapi/VideoStation/movie.cgi?api=SYNO.VideoStation.Movie&version=3&method=list&_sid=%@",ip,port,sid];
- NSURL *url = [NSURL URLWithString:urlString];
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
- NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
- NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
- NSURLSessionDataTask *apiCall = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
- NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
- NSLog(@"JSON: %@",json);
- NSLog(@"SID: %@", [[json objectForKey:@"data"] objectForKey:@"movies"]);
- }];
- [apiCall resume];
Ich komme mit der Abfrage bis zum Punkt movies. Ich möchte aber Beispielsweise title abfragen. Wenn ich dann die Zeile ändere in "NSLog(@"SID: %@", [[[json objectForKey:@"data"] objectForKey:@"movies"] objectForKey:@"title"]);" stürzt das Programm ab.
Hat vielleicht jemand Erfahrung mit JSON.
Mit freundlichen Grüssen
David