File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
stdlib/public/Darwin/Foundation Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -499,8 +499,9 @@ fileprivate struct _JSONKeyedEncodingContainer<K : CodingKey> : KeyedEncodingCon
499
499
}
500
500
501
501
public mutating func nestedContainer< NestedKey> ( keyedBy keyType: NestedKey . Type , forKey key: Key ) -> KeyedEncodingContainer < NestedKey > {
502
- let dictionary = NSMutableDictionary ( )
503
- self . container [ _converted ( key) . stringValue] = dictionary
502
+ let containerKey = _converted ( key) . stringValue
503
+ let dictionary = self . container [ containerKey] as? NSMutableDictionary ?? NSMutableDictionary ( )
504
+ self . container [ containerKey] = dictionary
504
505
505
506
self . codingPath. append ( key)
506
507
defer { self . codingPath. removeLast ( ) }
@@ -510,8 +511,9 @@ fileprivate struct _JSONKeyedEncodingContainer<K : CodingKey> : KeyedEncodingCon
510
511
}
511
512
512
513
public mutating func nestedUnkeyedContainer( forKey key: Key ) -> UnkeyedEncodingContainer {
513
- let array = NSMutableArray ( )
514
- self . container [ _converted ( key) . stringValue] = array
514
+ let containerKey = _converted ( key) . stringValue
515
+ let array = self . container [ containerKey] as? NSMutableArray ?? NSMutableArray ( )
516
+ self . container [ containerKey] = array
515
517
516
518
self . codingPath. append ( key)
517
519
defer { self . codingPath. removeLast ( ) }
You can’t perform that action at this time.
0 commit comments