2016-08-03 6 views
0

ように私は私が持っている中で、私のJSONデータを得ています。の保存JSONデータは、文字列のObjective C

@try 
{ 
    NSError *error; 
NSString *url_string = [NSString stringWithFormat: @"http://Share/scripts/newjson.json"]; 
///Dummy URL 
NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString:url_string]]; 
NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; 
NSLog(@"json: %@", json); 

} 
@catch (NSException *e) 
{ 
    NSLog(@"Internet not enabled"); 
    //something went wrong 
    //populate the NSError object so it can be accessed 
} 

しかし、私はJSONファイルをプリントアウトし、私はちょうど上に示しているものを得る、私はこの文字列を取得するには、区切り文字か何かを使用する必要がありますか?

おかげ

答えて

2

実際にJSONは辞書ではないアレイとnilOptionsない可変です。

書き込みブラッド

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; 
NSString *name = json[@"name"]; 
NSLog(@"name: %@", name); 
+0

歓声を取得するにはそれが働きました – Brad

関連する問題