@@ -347,15 +347,19 @@ -(BOOL)__importDictionary:(NSDictionary*)dict withKeyMapper:(JSONKeyMapper*)keyM
347
347
if (property.type == nil && property.structName ==nil ) {
348
348
349
349
// generic setter
350
- [self setValue: jsonValue forKey: property.name];
350
+ if (jsonValue != [self valueForKey: property.name]) {
351
+ [self setValue: jsonValue forKey: property.name];
352
+ }
351
353
352
354
// skip directly to the next key
353
355
continue ;
354
356
}
355
357
356
358
// 0.5) handle nils
357
359
if (isNull (jsonValue)) {
358
- [self setValue: nil forKey: property.name];
360
+ if ([self valueForKey: property.name] != nil ) {
361
+ [self setValue: nil forKey: property.name];
362
+ }
359
363
continue ;
360
364
}
361
365
@@ -378,7 +382,9 @@ -(BOOL)__importDictionary:(NSDictionary*)dict withKeyMapper:(JSONKeyMapper*)keyM
378
382
}
379
383
return NO ;
380
384
}
381
- [self setValue: value forKey: property.name];
385
+ if (![value isEqual: [self valueForKey: property.name]]) {
386
+ [self setValue: value forKey: property.name];
387
+ }
382
388
383
389
// for clarity, does the same without continue
384
390
continue ;
@@ -410,7 +416,9 @@ -(BOOL)__importDictionary:(NSDictionary*)dict withKeyMapper:(JSONKeyMapper*)keyM
410
416
}
411
417
412
418
// set the property value
413
- [self setValue: jsonValue forKey: property.name];
419
+ if (![jsonValue isEqual: [self valueForKey: property.name]]) {
420
+ [self setValue: jsonValue forKey: property.name];
421
+ }
414
422
continue ;
415
423
}
416
424
@@ -460,7 +468,9 @@ -(BOOL)__importDictionary:(NSDictionary*)dict withKeyMapper:(JSONKeyMapper*)keyM
460
468
jsonValue = [valueTransformer performSelector: selector withObject: jsonValue];
461
469
#pragma clang diagnostic pop
462
470
463
- [self setValue: jsonValue forKey: property.name];
471
+ if (![jsonValue isEqual: [self valueForKey: property.name]]) {
472
+ [self setValue: jsonValue forKey: property.name];
473
+ }
464
474
465
475
} else {
466
476
@@ -474,7 +484,9 @@ -(BOOL)__importDictionary:(NSDictionary*)dict withKeyMapper:(JSONKeyMapper*)keyM
474
484
475
485
} else {
476
486
// 3.4) handle "all other" cases (if any)
477
- [self setValue: jsonValue forKey: property.name];
487
+ if (![jsonValue isEqual: [self valueForKey: property.name]]) {
488
+ [self setValue: jsonValue forKey: property.name];
489
+ }
478
490
}
479
491
}
480
492
}
@@ -670,7 +682,7 @@ -(void)__inspectProperties
670
682
}
671
683
672
684
// add the property object to the temp index
673
- if (p) {
685
+ if (p && ![propertyIndex objectForKey: p.name] ) {
674
686
[propertyIndex setValue: p forKey: p.name];
675
687
}
676
688
}
0 commit comments