File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -228,13 +228,8 @@ public final class Mapper<N: Mappable> {
228228 * Maps an array of JSON dictionary to an array of object that conforms to Mappable
229229 */
230230 public func mapArray( JSONArray: [ [ String : AnyObject ] ] ) -> [ N ] {
231- return JSONArray . reduce ( [ ] ) { ( var values, JSON) in
232- // map every element in JSON array to type N
233- if let value = self . map ( JSON) {
234- values. append ( value)
235- }
236- return values
237- }
231+ // map every element in JSON array to type N
232+ return JSONArray . filterMap ( map)
238233 }
239234
240235 /** Maps a JSON object to a dictionary of Mappable objects if it is a JSON
@@ -252,15 +247,8 @@ public final class Mapper<N: Mappable> {
252247 * Maps a JSON dictionary of dictionaries to a dictionary of objects that conform to Mappable.
253248 */
254249 public func mapDictionary( JSONDictionary: [ String : [ String : AnyObject ] ] ) -> [ String : N ] {
255- return reduce ( JSONDictionary, [ String: N] ( ) ) { ( var values, element) in
256- let ( key, value) = element
257-
258- // map every value in dictionary to type N
259- if let newValue = self . map ( value) {
260- values [ key] = newValue
261- }
262- return values
263- }
250+ // map every value in dictionary to type N
251+ return JSONDictionary . filterMap ( map)
264252 }
265253
266254 // MARK: Functions that create JSON from objects
You can’t perform that action at this time.
0 commit comments