开发者

How do I retrieve a JSON parameter with into an NSArray/NSDictionary

开发者 https://www.devze.com 2023-02-03 01:42 出处:网络
I need help here. This is my JSON webservice http://webservice.creaworld.sg/vesselservice.ashx?test. Select the method getdatasetmem_serialize notice that the JSON data has a backslash or escape ch

I need help here.

This is my JSON webservice http://webservice.creaworld.sg/vesselservice.ashx?test.

Select the method getdatasetmem_serialize notice that the JSON data has a backslash or escape char in it.

Why is this happening?, and how do I retrieve the value in, lets sa开发者_C百科y, the i_member_id in Xcode? I know that the retrieved JSON data "Table" is an Array and it has 2 dictionaries in it.


Why do you need to parse serialized response? Can you parse normal JSON?

NSError *error;

NSDictionary *json = [parser objectWithString:content error:&error];
if ( json == nil ) {
    UIAlertView *errorAlert = [[UIAlertView alloc]
        initWithTitle:@"Error"
        message:[error localizedDescription]
        delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
        [errorAlert show];
        [errorAlert autorelease];
} else {
    NSArray *trends = [json objectForKey:@"trends"];
    for (NSDictionary *trend in trends) {
        [viewController.names addObject:[trend objectForKey:@"name"]];
        [viewController.urls addObject:[trend objectForKey:@"url"]];
    }
}
0

精彩评论

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