You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Foundation/NSJSONSerialization.swift
+24-17Lines changed: 24 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -503,21 +503,10 @@ private struct JSONWriter {
503
503
writer("\n")
504
504
incAndWriteIndent()
505
505
}
506
-
506
+
507
507
varfirst=true
508
508
509
-
varkeys=Array(dict.keys)
510
-
if sortedKeys {
511
-
try keys.sort(by:{ a, b in
512
-
guardlet a = a as?String,
513
-
let b = b as?Stringelse{
514
-
throwNSError(domain: NSCocoaErrorDomain, code:CocoaError.propertyListReadCorrupt.rawValue, userInfo:["NSDebugDescription":"NSDictionary key must be NSString"])
throwNSError(domain: NSCocoaErrorDomain, code:CocoaError.propertyListReadCorrupt.rawValue, userInfo:["NSDebugDescription":"NSDictionary key must be NSString"])
534
523
}
535
524
pretty ?writer(": "):writer(":")
536
-
tryserializeJSON(dict[key]!)
525
+
tryserializeJSON(value)
537
526
}
527
+
528
+
if sortedKeys {
529
+
letelems=try dict.sorted(by:{ a, b in
530
+
guardlet a = a.key as?String,
531
+
let b = b.key as?Stringelse{
532
+
throwNSError(domain: NSCocoaErrorDomain, code:CocoaError.propertyListReadCorrupt.rawValue, userInfo:["NSDebugDescription":"NSDictionary key must be NSString"])
0 commit comments