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.
2 parents 634c31c + 6f4a1c5 commit 5ec233eCopy full SHA for 5ec233e
Sources/TSCBasic/JSONMapper.swift
@@ -152,3 +152,21 @@ extension Double: JSONMappable {
152
self = double
153
}
154
155
+
156
+extension Array where Element: JSONMappable {
157
+ public init(json: JSON) throws {
158
+ guard case .array(let array) = json else {
159
+ throw JSON.MapError.custom(key: nil, message: "expected array, got \(json)")
160
+ }
161
+ self = try array.map({ try Element(json: $0) })
162
163
+}
164
165
+extension Dictionary where Key == String, Value: JSONMappable {
166
167
+ guard case .dictionary(let dictionary) = json else {
168
+ throw JSON.MapError.custom(key: nil, message: "expected dictionary, got \(json)")
169
170
+ self = try dictionary.mapValues({ try Value(json: $0) })
171
172
0 commit comments