Skip to content

Commit eacd5e9

Browse files
authored
Merge pull request #24904 from GeorgeLyon/master
2 parents b78fc1b + 38567f2 commit eacd5e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Darwin/Foundation-swiftoverlay/JSONEncoder.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,10 +1376,13 @@ fileprivate struct _JSONKeyedDecodingContainer<K : CodingKey> : KeyedDecodingCon
13761376
// In this case we can attempt to recover the original value by reversing the transform
13771377
let original = key.stringValue
13781378
let converted = JSONEncoder.KeyEncodingStrategy._convertToSnakeCase(original)
1379+
let roundtrip = JSONDecoder.KeyDecodingStrategy._convertFromSnakeCase(converted)
13791380
if converted == original {
13801381
return "\(key) (\"\(original)\")"
1381-
} else {
1382+
} else if roundtrip == original {
13821383
return "\(key) (\"\(original)\"), converted to \(converted)"
1384+
} else {
1385+
return "\(key) (\"\(original)\"), with divergent representation \(roundtrip), converted to \(converted)"
13831386
}
13841387
default:
13851388
// Otherwise, just report the converted string

0 commit comments

Comments
 (0)