且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用json为iphone解析对象数组

更新时间:2023-01-17 16:26:34

GoogleJSON框架。按照(简单)说明进行安装。

Google "JSON Framework". Follow the (easy) instructions to install it.

然后去:

//let's say there's NSString *jsonString.

NSArray *userData = [jsonString JSONValue];

NSMutableArray *creditCards = [NSMutableArray array];
for (NSDictionary *user in userData) {
    [creditCards addObject:[user objectForKey:@"creditCardNumber"]];
}

你将使用NSMutableArray * creditCards充满NSString而放弃底部包含信用卡号的对象。

You'll drop out the bottom of that with NSMutableArray *creditCards full of NSString objects containing the credit card numbers.