带有 Mantle 的嵌套对象映射 - Obj-c
Nested Object map with Mantle - Obj-c
我有这个 JSON,我正在用 mantle 映射它:
{
"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>\n\n<p>Here's the result, you be the judge :)</p>\n\n<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"
};
}
如何访问嵌套在“玩家”字典中的“名称”属性?
只需将 @"author"
设置为 @"player.name"
。
我有这个 JSON,我正在用 mantle 映射它:
{
"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>\n\n<p>Here's the result, you be the judge :)</p>\n\n<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"
};
}
如何访问嵌套在“玩家”字典中的“名称”属性?
只需将 @"author"
设置为 @"player.name"
。