가 json.txt에있는 콘텐츠입니다, JSONKit
내가idKey
및
title
및
budget
을 얻을 뭐하는 거지
{
"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"
}
]
}
}
]
}
는 내가 그런
@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'가 배열이라고 가정합니까? 위의 JSON에있는 것이 아니라 객체 ('NSDictionary')입니다. – Hejazi