以下是位于 json.txt 的内容
{
"data": [
{
"keyId": 3,
"title": "This is a fundraiser 1",
"budget": "1000",
"users": {
"user": [
{
"id": "3",
"first_name": "A1",
"last_name": "A11",
"is_owner": "false"
},
{
"id": "2",
"first_name": "B1",
"last_name": "B11",
"is_owner": "true"
}
]
}
}
]
}
我正在做什么来获得idKey
并且是title
budget
@implementation Account
@synthesize arr;
-(void)parse {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"fundraiser_json" ofType:@"txt"];
NSString *jsonString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
NSDictionary *dict = [jsonString objectFromJSONString];
self.arr = [dict objectForKey:@"data"];
for ( NSDictionary *acc in self.arr ) {
Account *account = [[Account alloc] init];
[account setKeyID: [acc objectForKey:@"keyId"]];
[account setTitle: [acc objectForKey:@"title"]];
[account setBudget: [acc objectForKey:@"budget"]];
}
}
然后我试图访问users
并获取其中的每个信息,user
但我不能
有人可以帮助我如何访问和获取这些数据。