嵌套对象映射与地幔 - Obj-c



我有这个JSON,我用地幔映射它:

{
        "comments_count" = 85;
        "created_at" = "2015/04/30 01:04:01 -0400";
        description = "<p>I've set myself a challenge to take something as simple as a potato and make a product page out of it.</p>nn<p>Here's the result, you be the judge :)</p>nn<p>Check out the full version and get a free potato <a href="https://dribbble.com/shots/2042501-Potato/attachments/363345" rel="nofollow">here</a>.</p>";
        height = 600;
        id = 2042501;
        "image_url" = "https://d13yacurqjgara.cloudfront.net/users/77760/screenshots/2042501/potato.jpg";
        "likes_count" = 769;
        player =         {
            id = 77760;
            "likes_count" = 1358;
            name = Eldin;
            "twitter_screen_name" = eldindesign;
            url = "http://dribbble.com/eldindesign";
            username = eldindesign;
        };
        "rebound_source_id" = "<null>";
        "rebounds_count" = 0;
        "short_url" = "http://drbl.in/oBsT";
        title = "Potato landing page";
        url = "http://dribbble.com/shots/2042501-Potato-landing-page";
        "views_count" = 8411;
    }

这是我的映射:

+ (NSDictionary *)JSONKeyPathsByPropertyKey
{
    // model_property_name : json_field_name
    return @{
             @"title"       : @"title",
             @"author"      : @"name",
             @"info"        : @"description",
             @"views_count" : @"views_count",
             @"image_url"   : @"image_url"
             };
}

如何访问嵌套在"播放器"字典中的"name"属性?

只需将@"author"设置为 @"player.name" 即可

相关内容

最新更新