File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -188,17 +188,11 @@ extension ASCIICharacter: Equatable {
188188
189189extension ASCIICharacter : Codable {
190190
191- enum CodingKeys : String , CodingKey {
192-
193- case asciiValue
194-
195- }
196-
197191 public init ( from decoder: Decoder ) throws {
198192
199- let container = try decoder. container ( keyedBy : CodingKeys . self )
200- let asciiValue = try container. decode ( UInt8 . self, forKey : . asciiValue )
201- guard let newInstance = Self ( asciiValue ) else {
193+ let container = try decoder. singleValueContainer ( )
194+ let string = try container. decode ( String . self)
195+ guard let newInstance = Self ( exactly : string ) else {
202196 throw DecodingError . dataCorrupted (
203197 . init( codingPath: container. codingPath,
204198 debugDescription: " Value was not valid ASCII character number. " )
@@ -210,9 +204,9 @@ extension ASCIICharacter: Codable {
210204
211205 public func encode( to encoder: Encoder ) throws {
212206
213- var container = encoder. container ( keyedBy : CodingKeys . self )
207+ var container = encoder. singleValueContainer ( )
214208
215- try container. encode ( asciiValue , forKey : . asciiValue )
209+ try container. encode ( String ( characterValue ) )
216210
217211 }
218212
You can’t perform that action at this time.
0 commit comments