我在数组中有一些值,使用字典我需要通过一些键值显示这些值
{
"table_id": "180PTTBL",
"table_name": "180 Points",
"stake": 100,
"game_type": "180PT"
}
请帮我解决这个问题
答案 0 :(得分:1)
您可以使用NSJSONSerialization
NSError *e = nil;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e];
if (!dict) {
NSLog(@"Error parsing JSON: %@", e);
} else {
.. do your stuff
}
答案 1 :(得分:-2)
NSString *jsonString = @"YOUR_JSON_STRING";
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"%@",[json objectForKey:@"table_id"]);