开发者

Getting NULL value parsing JSON string

I have this JSON data:

 {
    "data":{
        "mat_149":{
            "id":"149",
            "title":"The closing of 40% prof开发者_StackOverflow社区it within 9 month",
            "teaser":"profit within 9 months only which is equal to 52% annual profit",
            "body":" The auction was presented in a very high and commercial lands.\u000d\u000a",
            "files":{
                "911":{
                    "fid":"911",
                    "filename":"22.JPG",
                    "filepath":"http://mysite/files/22_0.JPG"
                }
            }
        },
        "mat_147":{
            "id":"147",
            "title":"Company launches the city ",
            "teaser":"demands for distinguished lands.",
            "body":" The area size is quare meters This is evident through projects and many other projects.\u000d\u000a\u000d\u000a",
            "files":{
                "906":{
                    "fid":"906",
                    "filename":"2D7z.jpg",
                    "filepath":"http://mysite/dlr/files/2D7Z.jpg"
                }
            }
        },
        "mat_link":"mysite.com/"
    }
}

I'm parsing it like this with the json-framework:

NSString *response = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding] ;
SBJSON *parser = [[SBJSON alloc] init];  
NSDictionary *data = (NSDictionary *) [parser objectWithString:response error:nil];  
NSLog(@"Data : %@", [data valueForKey:@"data"] );

I am getting NULL:

[2599:207] Data : (null)

Can someone point out what I'm doing wrong/how I can fix this?


try this one

   NSLog(@"Data : %@", [data objectForKey:@"data"] );

more over

  SBJSON *parser = [[[SBJSON alloc] init] autorelease];//should be release

For his modified questions

    for (NSMutableArray *arr in [data objectForKey:@"data"] ) {



        for (NSMutableArray *arr1 in [arr objectForKey:@"files"]) {


            for (NSMutableArray *arr2 in arr1) {




                NSLog(@"fid : %@ \n\n",[arr2 valueForKey:@"fid"]);

                NSLog(@"filename : %@ \n\n",[arr2 valueForKey:@"filename"]);

                NSLog(@"filepath : %@ \n\n",[arr2 valueForKey:@"filepath"]);


            }


        }


    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜