首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

嵌套json数据解析,该如何处理

2013-01-23 
嵌套json数据解析 category ({children ({id 3name %E9%95%BF%E8%A2%96T%E6%81%A4parentid 1

嵌套json数据解析
 category =         (
                        {
                children =                 (
                                        {
                        id = 3;
                        name = "%E9%95%BF%E8%A2%96T%E6%81%A4";
                        parentid = 1;
                    },
                                        {
                        id = 4;
                        name = "%E7%9F%AD%E8%A2%96T%E6%81%A4";
                        parentid = 1;
                    }
                );
                id = 1;
                name = "%E7%94%B7%E8%A3%85";
            },
                        {
                children =                 (
                                        {
                        id = 5;
                        name = "%E9%95%BF%E8%A2%96T%E6%81%A4";
                        parentid = 2;
                    }
                );


                id = 2;
                name = "%E5%A5%B3%E8%A3%85";
            },
                        {
                id = 1001;
                name = "%E5%AE%A0%E7%89%A9";
            },
                        {
                id = 1002;
                name = "%E4%BA%BA%E7%89%A9";
            },
                        {
                id = 1003;
                name = "%E7%89%A9%E5%93%81";
            },
                        {
                id = 1004;
                name = "%E8%A3%85%E9%A5%B0";
            }
        );

    NSDictionary* dicRoot = [SSParse JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
    NSDictionary* dicContent = [dicRoot objectForKey:@"content"];
    NSArray* arrCategory = [dicContent objectForKey:@"category"];

通过json将数据解析出来,最后 arrCategory获取到的数据如下,由于里面是一个嵌套结构,接受的是NSArray,如何嵌套解析出每一个子项。这里面有的有子项,有的没有,有什么好办法嘛。请赐教!
                       {
                children =                 (
                                        {
                        id = 3;
                        name = "%E9%95%BF%E8%A2%96T%E6%81%A4";
                        parentid = 1;
                    },


                                        {
                        id = 4;
                        name = "%E7%9F%AD%E8%A2%96T%E6%81%A4";
                        parentid = 1;
                    }
                );
                id = 1;
                name = "%E7%94%B7%E8%A3%85";
            },
                        {
                children =                 (
                                        {
                        id = 5;
                        name = "%E9%95%BF%E8%A2%96T%E6%81%A4";
                        parentid = 2;
                    }
                );
                id = 2;
                name = "%E5%A5%B3%E8%A3%85";
            },
                        {
                id = 1001;
                name = "%E5%AE%A0%E7%89%A9";
            },
                        {
                id = 1002;
                name = "%E4%BA%BA%E7%89%A9";
            },
                        {


                id = 1003;
                name = "%E7%89%A9%E5%93%81";
            },
                        {
                id = 1004;
                name = "%E8%A3%85%E9%A5%B0";
            }
[解决办法]
断点调试看看,dicRoot ,dicContent里面分别是些什么内容

热点排行