您可以通过以下方法简单地解析 JSON
NSString* strJSONResponse = @"{\"1\":\"03:30 PM To 04:30 PM\",\"2\":\"01:30 PM To 02:30 PM\",\"3\":\"02:30 AM To 03:30 PM\",\"4\":\"04:30 PM To 05:30 PM\",\"5\":\"05:30 PM To 06:30 PM\",\"6\":\"06:30 PM To 07:30 PM\"}";
NSDictionary* dataDict = [strJSONResponse JSONValue];
NSLog(@"%@",dataDict);
这是输出:
Printing description of dataDict:
{
1 = "03:30 PM To 04:30 PM";
2 = "01:30 PM To 02:30 PM";
3 = "02:30 AM To 03:30 PM";
4 = "04:30 PM To 05:30 PM";
5 = "05:30 PM To 06:30 PM";
6 = "06:30 PM To 07:30 PM";
}
有了这本词典,您可以根据您的要求简单地使用。
在这里,您需要包含此处找到的 SBJSON 所需的类
我必须添加“\”作为转义字符才能将其用作字符串。
希望能帮助到你