我从UPX服务器接收到JSON数组,但我无法获得一个值

我需要来自“ relation_data”的对象“ name”,但我无法进入“ relation_data”

这就是我的方法

NSLog(@"All of the arrays: %@", json);
    NSDictionary *Allinfo = [json objectForKey:@"response"];//I go into "response"
    NSLog(@"All with response array: %@", Allinfo);
    NSDictionary *datainfo = [Allinfo objectForKey:@"data"];//i go into "data"
    NSLog(@"Data : %@", datainfo);


但是,如何进入“ relation_data”并获取“名称”的值?

response = (
data =     (
                        {
                    "business_data_rev" = 12;
                    "contact_set_rev" = 15;
                    currency = EUR;
                    "date_added" = "2011-08-31 12:10:59.338664+02";
                    "date_invoiced" = "2011-08-31 12:10:59.338664+02";
                    "date_modified" = "2011-08-31 12:11:04.45442+02";
                    "date_paid" = "2011-08-31 12:10:59.408335+02";
                    description = "";
                    id = 104;
                    name = "Invoice #104";
                    "person_rev" = 12;
                    realid = 104;
                    "relation_data" =             {
                        id = 12;
                        iscreditor = 0;
                        isdebitor = 1;
                        isprivate = 0;
                        name = "Emre.";
                        "subaccount_id" = 9;
                    };
        )

最佳答案

尝试这个

[dataInfo valueForKeyPath:@"relation_data.name"];

关于objective-c - 从JSON数组objective-c获取值时出现问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7257474/

10-12 07:07