|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 | NSString* jsonString =   @"{\"info\":{\"error\":0,\"type\":34},\"poilist\":[{\"name\":\"银科大厦\",\"x\":116.345,\"y\":39.3334},{\"name\":\"中国技术交易大厦\",\"x\":116.3451,\"y\":39.31334}]}";
    
    id root = [jsonString objectFromJSONString];
    
    if ([root isKindOfClass:[NSDictionary class]]) {
        
        id jsonInfo = [root objectForKey:@"info"];
        
        if ([jsonInfo isKindOfClass:[NSDictionary class]]) {
            NSInteger error = [[jsonInfo objectForKey:@"error"] intValue];
            NSInteger type = [[jsonInfo objectForKey:@"type"] intValue];
            
            NSLog(@"error = %d,type = %d",error,type);
        }
        
        id jsonPoiList = [root objectForKey:@"poilist"];
        
        if ([jsonPoiList isKindOfClass:[NSArray class]]) {
            NSArray* jsonPoiArray = (NSArray*)jsonPoiList;
            
            for (id jsonPoiDic in jsonPoiArray) {
                
                if ([jsonPoiDic isKindOfClass:[NSDictionary class]]) {
                    NSString* name = [jsonPoiDic objectForKey:@"name"];
                    double x = [[jsonPoiDic objectForKey:@"x"] doubleValue];
                    double y = [[jsonPoiDic objectForKey:@"y"] doubleValue];
                    
                    NSLog(@"poi:{name=%@,x=%f,y=%f}",name,x,y);
                    
                }
            }
        }
    }
 |