Parcourir la source

updated test case

ibireme il y a 9 ans
Parent
commit
a437526cc4
2 fichiers modifiés avec 5 ajouts et 4 suppressions
  1. 2 4
      YYModel/NSObject+YYModel.m
  2. 3 0
      YYModelTests/YYTestModelToJSON.m

+ 2 - 4
YYModel/NSObject+YYModel.m

@@ -1198,10 +1198,8 @@ static id ModelToJSONObjectRecursive(NSObject *model) {
                 subDic = superDic[key];
                 if (subDic) {
                     if ([subDic isKindOfClass:[NSDictionary class]]) {
-                        if (![subDic isKindOfClass:[NSMutableDictionary class]]) {
-                            subDic = subDic.mutableCopy;
-                            superDic[key] = subDic;
-                        }
+                        subDic = subDic.mutableCopy;
+                        superDic[key] = subDic;
                     } else {
                         break;
                     }

+ 3 - 0
YYModelTests/YYTestModelToJSON.m

@@ -138,6 +138,9 @@
     XCTAssert([ext[@"b"] isEqualToString:@"b"]);
     XCTAssert([ext[@"a"] isEqualToString:@"a"] || [ext[@"a"] isEqualToString:@"c"]);
     
+    model.f = @{@"g" : @""};
+    dic = [model yy_modelToJSONObject];
+    
 }
 
 - (void)testDate {