I try to convert a dictionary, with Int enum
enum TypeE: Int, Codable
{
case note = 1
case tab
}
let encoder = JSONEncoder()
let dictionary0 = [TypeE.note:"VALUE0", TypeE.tab:"VALUE1"]
var data = try encoder.encode(dictionary0)
var string = String(data: data, encoding: .utf8)!
// [1,"VALUE0",2,"VALUE1"]
print(string)
The produced json string output is
[1,"VALUE0",2,"VALUE1"]
It looks strange to me. As, the produced json string represents an array.
If I tested with
let encoder = JSONEncoder()
let dictionary1 = [1:"VALUE0", 2:"VALUE1"]
var data = try encoder.encode(dictionary1)
var string = String(data: data, encoding: .utf8)!
// {"1":"VALUE0","2":"VALUE1"}
print(string)
The produced json string output is
{"1":"VALUE0","2":"VALUE1"}
It seems like if I use Int enum as dictionary key, the produced json string will become representation of array?
Is there any mistake in my code, or my expectation is incorrect?

