Ниже представлен контент, расположенный в файле 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
в нем, но я не могу
Может кто-нибудь помочь мне, как получить доступ и получить эти данные.
users
, потому что я не обратил внимания, чтоusers
также является еще одним словарем. Спасибо за вашу помощь.. 15.08.2012