UPDATE-8/31/12-所以现在我需要通过基于“isReservable”= 1 的字典数组,然后显示“开始”。我只是想获取每个字典数组的内容,我可以从那里开始(现在)。以下是我尝试过的。感谢大家的帮助,我每天都在学习更多。
来自php页面的json
{
"slots": {
"2012-08-31 00:00:00 America/Los_Angeles": [
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-30 17:00:00 America/Los_Angeles",
"end": "2012-08-30 17:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-30 17:30:00 America/Los_Angeles",
"end": "2012-08-30 18:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": false,
"isReserved": false,
"label": " ",
"begin": "2012-08-30 18:00:00 America/Los_Angeles",
"end": "2012-08-31 00:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": false,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 00:00:00 America/Los_Angeles",
"end": "2012-08-31 08:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 08:00:00 America/Los_Angeles",
"end": "2012-08-31 08:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 08:30:00 America/Los_Angeles",
"end": "2012-08-31 09:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 09:00:00 America/Los_Angeles",
"end": "2012-08-31 09:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 09:30:00 America/Los_Angeles",
"end": "2012-08-31 10:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": false,
"isReserved": true,
"label": "Thomas Kroom",
"begin": "2012-08-31 10:00:00 America/Los_Angeles",
"end": "2012-08-31 12:30:00 America/Los_Angeles",
"span": 5
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 12:30:00 America/Los_Angeles",
"end": "2012-08-31 13:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 13:00:00 America/Los_Angeles",
"end": "2012-08-31 13:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 13:30:00 America/Los_Angeles",
"end": "2012-08-31 14:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 14:00:00 America/Los_Angeles",
"end": "2012-08-31 14:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 14:30:00 America/Los_Angeles",
"end": "2012-08-31 15:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 15:00:00 America/Los_Angeles",
"end": "2012-08-31 15:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 15:30:00 America/Los_Angeles",
"end": "2012-08-31 16:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 16:00:00 America/Los_Angeles",
"end": "2012-08-31 16:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 16:30:00 America/Los_Angeles",
"end": "2012-08-31 17:00:00 America/Los_Angeles",
"span": 1
}
],
"2012-09-01 00:00:00 America/Los_Angeles": [
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 17:00:00 America/Los_Angeles",
"end": "2012-08-31 17:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 17:30:00 America/Los_Angeles",
"end": "2012-08-31 18:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": false,
"isReserved": false,
"label": " ",
"begin": "2012-08-31 18:00:00 America/Los_Angeles",
"end": "2012-09-01 00:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": false,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 00:00:00 America/Los_Angeles",
"end": "2012-09-01 08:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 08:00:00 America/Los_Angeles",
"end": "2012-09-01 08:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 08:30:00 America/Los_Angeles",
"end": "2012-09-01 09:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 09:00:00 America/Los_Angeles",
"end": "2012-09-01 09:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 09:30:00 America/Los_Angeles",
"end": "2012-09-01 10:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 10:00:00 America/Los_Angeles",
"end": "2012-09-01 10:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 10:30:00 America/Los_Angeles",
"end": "2012-09-01 11:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 11:00:00 America/Los_Angeles",
"end": "2012-09-01 11:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 11:30:00 America/Los_Angeles",
"end": "2012-09-01 12:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 12:00:00 America/Los_Angeles",
"end": "2012-09-01 12:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 12:30:00 America/Los_Angeles",
"end": "2012-09-01 13:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 13:00:00 America/Los_Angeles",
"end": "2012-09-01 13:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 13:30:00 America/Los_Angeles",
"end": "2012-09-01 14:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 14:00:00 America/Los_Angeles",
"end": "2012-09-01 14:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 14:30:00 America/Los_Angeles",
"end": "2012-09-01 15:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 15:00:00 America/Los_Angeles",
"end": "2012-09-01 15:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 15:30:00 America/Los_Angeles",
"end": "2012-09-01 16:00:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 16:00:00 America/Los_Angeles",
"end": "2012-09-01 16:30:00 America/Los_Angeles",
"span": 1
},
{
"isPending": false,
"isReservable": true,
"isReserved": false,
"label": " ",
"begin": "2012-09-01 16:30:00 America/Los_Angeles",
"end": "2012-09-01 17:00:00 America/Los_Angeles",
"span": 1
}
]
}
这是我到目前为止所拥有的
- (void)fetchedData:(NSData *)responseData {
//parse out the json data
NSError* error;
//NSLog(@"string is %@", responseData);
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
NSDictionary* myslots =[json objectForKey:@"slots"];
NSLog(@"allslots: %@", myslots);
//for (NSString *slotKey in myslots.allKeys) {
//NSDictionary *slot = [myslots valueForKey:slotKey];
//NSLog(@"These are all the keys: %@", slotKey);
NSArray *keys = [myslots allKeys];
更新 - 这就是我让它工作的方式:
for (NSString *slotKey in myslots.allKeys) {
NSDictionary *slot = [myslots valueForKey:slotKey];
NSArray *tests = [myslots objectForKey:slotKey];
for (NSDictionary *myDict in tests){
NSLog(@"%@", [myDict objectForKey:@"begin"]);
}
}
现在我只需要把它改成 if "isReservable" = true 然后显示 "begin"