Open
Description
Previous ID | SR-12588 |
Radar | rdar://problem/62202368 |
Original Reporter | @aciidb0mb3r |
Type | Bug |
Additional Detail from JIRA
Votes | 1 |
Component/s | Compiler, Foundation |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: f44fa76a09602e1ef66b339697c43ca2
Issue Description:
The following code produces different output on each invocation.
import Foundation
enum Key: String, Codable {
case a, b, c
}
struct MyStruct: Encodable {
var foo: [Key: Int]
}
let t = MyStruct(foo: [
.a: 1,
.b: 1,
.c: 1,
])
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .prettyPrinted]
let encoded = try encoder.encode(t)
print(String(data: encoded, encoding: .utf8)!)