We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9299038 commit 720ccffCopy full SHA for 720ccff
Sources/Lookup/Lookup.swift
@@ -574,6 +574,21 @@ public extension Lookup {
574
}
575
576
577
+// MARK: Decode
578
+extension Lookup {
579
+
580
+ public enum DecodeError: Swift.Error {
581
+ case invalidJSONData
582
+ }
583
584
+ public func decode<D>(as decodable: D.Type, using decoder: JSONDecoder = JSONDecoder()) throws -> D where D: Decodable {
585
+ guard let jsonData else {
586
+ throw DecodeError.invalidJSONData
587
588
+ return try decoder.decode(D.self, from: jsonData)
589
590
+}
591
592
593
// MARK: - Operator
594
public func + (lhs: Lookup, rhs: Lookup) -> Lookup {
0 commit comments