diff --git a/Sources/PostgresKit/Deprecations/PostgresDataDecoder+JSONDecoder.swift b/Sources/PostgresKit/Deprecations/PostgresDataDecoder+JSONDecoder.swift new file mode 100644 index 0000000..e1e9bab --- /dev/null +++ b/Sources/PostgresKit/Deprecations/PostgresDataDecoder+JSONDecoder.swift @@ -0,0 +1,8 @@ +import class Foundation.JSONDecoder + +extension PostgresDataDecoder { + @available(*, deprecated, renamed: "json") + public var jsonDecoder: JSONDecoder { + return self.json as! JSONDecoder + } +} diff --git a/Sources/PostgresKit/PostgresDataDecoder.swift b/Sources/PostgresKit/PostgresDataDecoder.swift index 11ccfdc..7c736e7 100644 --- a/Sources/PostgresKit/PostgresDataDecoder.swift +++ b/Sources/PostgresKit/PostgresDataDecoder.swift @@ -1,10 +1,12 @@ import Foundation +import protocol PostgresNIO.PostgresJSONDecoder +import var PostgresNIO._defaultJSONDecoder public final class PostgresDataDecoder { - public let jsonDecoder: JSONDecoder + public let json: PostgresNIO.PostgresJSONDecoder - public init(json: JSONDecoder = JSONDecoder()) { - self.jsonDecoder = json + public init(json: PostgresNIO.PostgresJSONDecoder = PostgresNIO._defaultJSONDecoder) { + self.json = json } public func decode(_ type: T.Type, from data: PostgresData) throws -> T @@ -19,7 +21,7 @@ public final class PostgresDataDecoder { } return value as! T } else { - return try T.init(from: _Decoder(data: data, json: self.jsonDecoder)) + return try T.init(from: _Decoder(data: data, json: self.json)) } } @@ -47,9 +49,9 @@ public final class PostgresDataDecoder { } let data: PostgresData - let json: JSONDecoder + let json: PostgresJSONDecoder - init(data: PostgresData, json: JSONDecoder) { + init(data: PostgresData, json: PostgresJSONDecoder) { self.data = data self.json = json } @@ -93,7 +95,7 @@ public final class PostgresDataDecoder { var currentIndex: Int = 0 let data: [PostgresData] - let json: JSONDecoder + let json: PostgresJSONDecoder var codingPath: [CodingKey] { [] } @@ -128,7 +130,7 @@ public final class PostgresDataDecoder { struct _ValueDecoder: SingleValueDecodingContainer { let data: PostgresData - let json: JSONDecoder + let json: PostgresJSONDecoder var codingPath: [CodingKey] { [] } diff --git a/Sources/PostgresKit/PostgresDataEncoder.swift b/Sources/PostgresKit/PostgresDataEncoder.swift index 0f5f2f0..e60d748 100644 --- a/Sources/PostgresKit/PostgresDataEncoder.swift +++ b/Sources/PostgresKit/PostgresDataEncoder.swift @@ -1,9 +1,11 @@ import Foundation +import protocol PostgresNIO.PostgresJSONEncoder +import var PostgresNIO._defaultJSONEncoder public final class PostgresDataEncoder { - public let json: JSONEncoder + public let json: PostgresJSONEncoder - public init(json: JSONEncoder = JSONEncoder()) { + public init(json: PostgresJSONEncoder = PostgresNIO._defaultJSONEncoder) { self.json = json }