{"id":176721,"date":"2013-04-15T15:15:03","date_gmt":"2013-04-15T11:15:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=176721"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=176721","title":{"rendered":"<span class=\"post_title\">EasyMapping, \u0438\u043b\u0438 \u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043f\u043e JSON&#8217;\u0443<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<blockquote><p>Computer programs are the most complex things that humans make. It is also the nature of software to be extensively modified over its productive life. If we can read and understand it, then we can hope to modify and improve it. <\/p>\n<p>  \u00a9 Douglas Crockford, \u0430\u0432\u0442\u043e\u0440 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 JSON<\/p><\/blockquote>\n<p>  JSON \u2014 \u044d\u0442\u043e \u043c\u043e\u0441\u0442 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043c\u0438\u0440\u0430\u043c\u0438: \u043c\u0438\u0440\u043e\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043c\u0438\u0440\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u043e\u0441\u0442 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c, \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0438\u0448\u0435\u043c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c, \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c. <\/p>\n<p>  \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f JSON \u0432 Objective-C \u043e\u0431\u044c\u0435\u043a\u0442\u044b, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0415\u0441\u0442\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u0438\u043c\u0438 <a href=\"https:\/\/github.com\/RestKit\/RestKit\">RestKit<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e REST API. \u0428\u0430\u0433 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u2014 \u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u0430\u0431\u0438\u0432\u0430\u0442\u044c \u0433\u0432\u043e\u0437\u0434\u0438 \u043c\u0438\u043a\u0440\u043e\u0441\u043a\u043e\u043f\u043e\u043c, \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044f, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432\u0435\u0449\u0435\u0439. \u0415\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 GitHub \u2014 <a href=\"https:\/\/github.com\/github\/Mantle\">Mantle<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u0441 \u043d\u0438\u043c \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Mantle \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/developer.apple.com\/library\/ios\/#documentation\/Cocoa\/Reference\/Foundation\/Classes\/NSValueTransformer_Class\/Reference\/Reference.html\">NSValueTransformer<\/a> \u2014 \u043d\u0435 \u0441\u0430\u043c\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0443\u044e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e \u0432 iOS\/Mac OS \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<p>  \u042f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430\u0448\u0435\u043b\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 GitHub, \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c JSON \u0432 Objective-C \u043e\u0431\u044c\u0435\u043a\u0442\u044b \u2014 <a href=\"https:\/\/github.com\/lucasmedeirosleite\/EasyMapping\">EasyMapping<\/a>. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438\u0441\u044c, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442!<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0417\u0430\u0434\u0430\u0447\u0430<\/h4>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 JSON: <\/p>\n<pre><code class=\"javascript\">{     &quot;name&quot;: &quot;Lucas&quot;,     &quot;email&quot;: &quot;notexisting@gmail.com&quot;,     &quot;gender&quot; : &quot;male&quot;,     &quot;car&quot;: {         &quot;model&quot;: &quot;i30&quot;,         &quot;year&quot;: &quot;2013&quot;     },     &quot;phones&quot;: [         {             &quot;ddi&quot;: &quot;55&quot;,             &quot;ddd&quot;: &quot;85&quot;,             &quot;number&quot;: &quot;1111-1111&quot;         },         {             &quot;ddi&quot;: &quot;55&quot;,             &quot;ddd&quot;: &quot;11&quot;,             &quot;number&quot;: &quot;2222-222&quot;         }     ] }<\/code><\/pre>\n<p>  \u0412 Objective-C \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b:<\/p>\n<pre><code class=\"objectivec\">typedef enum {     GenderMale,     GenderFemale } Gender;  @interface Person : NSObject  @property (nonatomic, copy)   NSString *name; @property (nonatomic, copy)   NSString *email; @property (nonatomic, assign) Gender gender; @property (nonatomic, strong) Car *car; @property (nonatomic, strong) NSArray *phones;  @end  @interface Car : NSObject  @property (nonatomic, copy) NSString *model; @property (nonatomic, copy) NSString *year;  @end  @interface Phone : NSObject  @property (nonatomic, copy) NSString *DDI; @property (nonatomic, copy) NSString *DDD; @property (nonatomic, copy) NSString *number;  @end <\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 (EKObjectMapping), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"objectivec\">EKObjectMapping * mapping = [[EKObjectMapping alloc] initWithObjectClass:[Person class]]; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 &lt;\u043a\u043b\u044e\u0447 \u0432 JSON&gt; -&gt; &lt;\u0438\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044c\u0435\u043a\u0442\u0430&gt;. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u044d\u0442\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 EasyMapping.<\/p>\n<p>  <b>1. \u041a\u043b\u044e\u0447\u0438 \u0432 JSON \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044c\u0435\u043a\u0442\u0430<\/b><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 Person:<\/p>\n<pre><code class=\"objectivec\">[mapping mapFieldsFromArray:@[@&quot;name&quot;,@&quot;email&quot;]]; <\/code><\/pre>\n<p>  <b>2. \u041a\u043b\u044e\u0447\u0438 \u0432 JSON \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044c\u0435\u043a\u0442\u0430<\/b><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 Phone:<\/p>\n<pre><code class=\"objectivec\">[mapping mapFieldsFromDictionary:@{@&quot;ddi&quot;:@&quot;DDI&quot;, @&quot;ddd&quot;:@&quot;DDD&quot;}]; <\/code><\/pre>\n<p>  <b>3. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <\/b><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 Person<\/p>\n<pre><code class=\"objectivec\">NSDictionary *genders = @{ @&quot;male&quot;: @(GenderMale), @&quot;female&quot;: @(GenderFemale) }; [mapping mapKey:@&quot;gender&quot; toField:@&quot;gender&quot; withValueBlock:^(NSString *key, id value) {     return genders[value]; }];  <\/code><\/pre>\n<p>  <b>4. \u041e\u0431\u044c\u0435\u043a\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0431\u044c\u0435\u043a\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430<\/b><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 Person<\/p>\n<pre><code class=\"objectivec\">[mapping hasOneMapping:[Car mapping] forKey:@&quot;car&quot;]; <\/code><\/pre>\n<p>  <b>5. \u041e\u0431\u044c\u0435\u043a\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430<\/b><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440. \u041a\u043b\u0430\u0441\u0441 Person<\/p>\n<pre><code class=\"objectivec\">[mapping hasManyMapping:[Phone mapping] forKey:@&quot;phones&quot;]; <\/code><\/pre>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h4>\n<p>  \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<pre><code class=\"objectivec\">+ (EKObjectMapping *)carMapping { \tEKObjectMapping * mapping = [[EKObjectMapping alloc] initWithObjectClass:[Car class]];      [mapping mapFieldsFromArray:@[@&quot;model&quot;, @&quot;year&quot;]];      return mapping; }  + (EKObjectMapping *)phoneMapping { \tEKObjectMapping * mapping = [[EKObjectMapping alloc] initWithObjectClass:[Phone class]];     [mapping mapFieldsFromArray:@[@&quot;number&quot;]];     [mapping mapFieldsFromDictionary:@{         @&quot;ddi&quot; : @&quot;DDI&quot;,         @&quot;ddd&quot; : @&quot;DDD&quot;      }];     return mapping; }  + (EKObjectMapping *)personMapping { \tEKObjectMapping * mapping = [[EKObjectMapping alloc] initWithObjectClass:[Person class]];      NSDictionary *genders = @{ @&quot;male&quot;: @(GenderMale), @&quot;female&quot;: @(GenderFemale) };     [mapping mapFieldsFromArray:@[@&quot;name&quot;, @&quot;email&quot;]];     [mapping mapKey:@&quot;gender&quot; toField:@&quot;gender&quot; withValueBlock:^(NSString *key, id value) {         return genders[value];     }];     [mapping hasOneMapping:[self carMapping] forKey:@&quot;car&quot;];     [mapping hasManyMapping:[self phoneMapping] forKey:@&quot;phones&quot;];      return mapping; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0433\u043e\u0442\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044c\u0435\u043a\u0442\u0430 Person \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"objectivec\">NSDictionary * personProperties = ...; \/\/ JSON \u043e\u0431\u044c\u0435\u043a\u0442\u0430 Person, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435, \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0435\u043d\u043d\u044b\u0439 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. Person * person = [[Person alloc] init]; [EKMapper fillObject:person fromExternalRepresentation:personProperties withMapping:mapping]; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044c\u0435\u043a\u0442\u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 if-else, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 NSNull. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u0431\u044c\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442.<\/p>\n<h5>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043b\u044e\u0448\u043a\u0438 EasyMapping<\/h5>\n<p>  1. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 CoreData<br \/>  2. \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 NSNull \u2014 NSNull \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 nil.<br \/>  3. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432 \u0432 NSDictionary\/NSArray<br \/>  4. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 CocoaPods<br \/>  5. \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043a\u0440\u044b\u0442 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<h5>\u0423\u0434\u0430\u0447\u043d\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h5>\n<p>  \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u044c\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 EKMapper \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0441\u043a\u0430\u0436\u0435\u043c, BaseModel, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"objectivec\">- (id)initWithProperties:(NSDictionary *)properties {     if (self = [super init])     {         [EKMapper fillObject:self fromExternalRepresentation:properties                  withMapping:[[self class] objectMapping];     }     return self; }  + (EKObjectMapping *)objectMapping {     \/\/Do nothing. Implement in subclass if you want to initialize object     \/\/via object mapping     return nil; } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044c\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"objectivec\">Person * person = [[Person alloc] initWithProperties:personProperties]; <\/code><\/pre>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <\/h4>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 open-source \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u2014 \u044d\u0442\u043e \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u043f\u0440\u044b\u0433\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435 \u0438 \u0432\u044b\u0448\u0435. \u041f\u0440\u043e\u0435\u043a\u0442\u0443 EasyMapping \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u043c\u0435\u0441\u044f\u0446, \u0435\u0441\u043b\u0438 \u0441\u0443\u0434\u0438\u0442\u044c \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043a\u043e\u043c\u043c\u0438\u0442\u0443, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u043d \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043f\u0435\u0440\u043d\u0438\u0447\u0430\u0442\u044c \u0441 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0436\u0435\u043b\u0430\u0442\u044c \u0443\u0434\u0430\u0447\u0438 \u0430\u0432\u0442\u043e\u0440\u0443 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u0430 \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u043e \u043a\u043e\u043d\u0446\u0430, \u2014 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u0443\u0434\u0430\u0447\u0438 \u0432 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u044f\u0445 \u043f\u043e JSON&#8217;\u0443!<\/p>\n<h4>\u0421\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  1. <a href=\"https:\/\/github.com\/lucasmedeirosleite\/EasyMapping\">EasyMapping \u043d\u0430 github<\/a> <br \/>  2. <a href=\"http:\/\/cocoapods.org\/\">CocoaPods<\/a> <\/p>\n<h5>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h5>\n<p>  1. <a href=\"https:\/\/github.com\/RestKit\/RestKit\">RestKit<\/a> <br \/>  2. <a href=\"https:\/\/github.com\/github\/Mantle\">Mantle<\/a> \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/176721\/\"> http:\/\/habrahabr.ru\/post\/176721\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<blockquote><p>Computer programs are the most complex things that humans make. It is also the nature of software to be extensively modified over its productive life. If we can read and understand it, then we can hope to modify and improve it. <\/p>\n<p>  \u00a9 Douglas Crockford, \u0430\u0432\u0442\u043e\u0440 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 JSON<\/p><\/blockquote>\n<p>  JSON \u2014 \u044d\u0442\u043e \u043c\u043e\u0441\u0442 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043c\u0438\u0440\u0430\u043c\u0438: \u043c\u0438\u0440\u043e\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043c\u0438\u0440\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u043e\u0441\u0442 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c, \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0438\u0448\u0435\u043c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c, \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c. <\/p>\n<p>  \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f JSON \u0432 Objective-C \u043e\u0431\u044c\u0435\u043a\u0442\u044b, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0415\u0441\u0442\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u0438\u043c\u0438 <a href=\"https:\/\/github.com\/RestKit\/RestKit\">RestKit<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e REST API. \u0428\u0430\u0433 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u2014 \u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u0430\u0431\u0438\u0432\u0430\u0442\u044c \u0433\u0432\u043e\u0437\u0434\u0438 \u043c\u0438\u043a\u0440\u043e\u0441\u043a\u043e\u043f\u043e\u043c, \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044f, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432\u0435\u0449\u0435\u0439. \u0415\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 GitHub \u2014 <a href=\"https:\/\/github.com\/github\/Mantle\">Mantle<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u0441 \u043d\u0438\u043c \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Mantle \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/developer.apple.com\/library\/ios\/#documentation\/Cocoa\/Reference\/Foundation\/Classes\/NSValueTransformer_Class\/Reference\/Reference.html\">NSValueTransformer<\/a> \u2014 \u043d\u0435 \u0441\u0430\u043c\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0443\u044e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e \u0432 iOS\/Mac OS \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<p>  \u042f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430\u0448\u0435\u043b\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 GitHub, \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c JSON \u0432 Objective-C \u043e\u0431\u044c\u0435\u043a\u0442\u044b \u2014 <a href=\"https:\/\/github.com\/lucasmedeirosleite\/EasyMapping\">EasyMapping<\/a>. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438\u0441\u044c, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442!  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-176721","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=176721"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176721\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}