Avatar
@swift-5.4.3 import Foundation enum Key: String, Codable { case a, b } let data = [Key.a: "A", Key.b: "B"] let json = try String(data: JSONEncoder().encode(data), encoding: .utf8)! print(json)