MAC解析JSON

    
    NSError *parseError;
    NSData *jsonData = [sJsonText dataUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:&parseError];
    if (json == nil)
    {
        NSLog(@"json parse failed. \r\n");
        //NSLog([[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);
        NSLog(@"%@",[parseError localizedDescription]);
        return;
    }

    NSArray *jijinArray = [json objectForKey:@"jijinlist"];
    for(NSDictionary *jijin in jijinArray)
    {
        NSString *sCode = [jijin objectForKey:@"code"];
        NSString *sValuein = [jijin objectForKey:@"valuein"];
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

*