We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5bce789 commit a3c6024Copy full SHA for a3c6024
Source/JSONJoy.swift
@@ -103,7 +103,23 @@ open class JSONDecoder {
103
return value as? [JSONDecoder]
104
}
105
106
-
+ /**
107
+ get typed `Array` of `JSONJoy` as an optional
108
+ */
109
+ public func getOptional<T: JSONJoy>() -> [T]? {
110
+ guard let a = getOptionalArray() else { return nil }
111
+ do { return try a.reduce([T]()) { $0.0 + [try T($0.1)] } }
112
+ catch { return nil }
113
+ }
114
+
115
116
117
118
+ public func getOptional<T: JSONBasicType>() -> [T]? {
119
120
+ do { return try a.reduce([T]()) { $0.0 + [try $0.1.get()] } }
121
122
123
124
/**
125
Array access support
0 commit comments