I came across this behavior that I don't really understand.
enum Key: String, Encodable {
case Key1
case Key2
}
let dict: [Key: String] = [.Key1: "Value1", .Key2: "Value2"]
let data = try! JSONEncoder().encode(dict)
let json = String(data: data, encoding: .utf8)!
// json value is ["Key1", "Value1", "Key2", "Value2"], which is an Array
// I expect json value to be ["Key1": "Value1", "Key2": "Value2"]
When I replace enum keys with String keys it works as expected. I'm using Swift 5.5.
Is this a bug or am I missing something?