我正在调用一个API,该API以JSON
格式返回一些高级数据。然后将其像这样处理成NSDictionary
;
NSDictionary *results = [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:&error];
当我登录时,我会得到一个非常复杂的结果,类似于以下内容:
{
one = {
oneone = 12345;
onetwo = "Hello";
onethree = "How Are You";
};
two = 42;
three = {
threeone = {
threeoneone = "Name";
threeonetwo = {
threeonetwoone = "100";
threeonetwotwo = "26";
};
etc etc etc
现在,我通过调用
[results objectForKey:@"three"]
获得了“threeonetwoone”的值,但是如何获得“threeonetwoone”的值呢?我尝试了几件事,但无济于事。
最佳答案
在您的情况下:
NSString* threeoneone= dict[@"three"][@"threeone"][@"threeonetoone"];