@@ -274,9 +274,9 @@ extension JSON {
274274 /// - Parameters:
275275 /// - keys: A dictionary containing key mappings, in the format of ["Old": "New"].
276276 /// - valueTransform: An optional value transform closure. Key represents the new key name.
277- public func mapKeys ( _ keys: [ String : String ] , valueTransform: ( ( _ key: String , _ value: Any ) -> Any ) ? = nil ) throws -> JSON {
277+ public func mapTransform ( _ keys: [ String : String ] , valueTransform: ( ( _ key: String , _ value: Any ) -> Any ) ? = nil ) throws -> JSON {
278278 guard let dict = self . dictionaryValue else { return self }
279- let mapped = try dict. mapKeys ( keys, valueTransform: valueTransform)
279+ let mapped = try dict. mapTransform ( keys, valueTransform: valueTransform)
280280 let result = try JSON ( mapped)
281281 return result
282282 }
@@ -285,7 +285,7 @@ extension JSON {
285285// MARK: - Helpers
286286
287287extension Dictionary where Key == String , Value == Any {
288- internal func mapKeys ( _ keys: [ String : String ] , valueTransform: ( ( _ key: Key , _ value: Value ) -> Any ) ? = nil ) throws -> [ Key : Value ] {
288+ internal func mapTransform ( _ keys: [ String : String ] , valueTransform: ( ( _ key: Key , _ value: Value ) -> Any ) ? = nil ) throws -> [ Key : Value ] {
289289 let mapped = Dictionary ( uniqueKeysWithValues: self . map { key, value -> ( Key , Value ) in
290290 var newKey = key
291291 var newValue = value
@@ -299,7 +299,7 @@ extension Dictionary where Key == String, Value == Any {
299299 }
300300 // is this value a dictionary?
301301 if let dictValue = value as? [ Key : Value ] {
302- if let r = try ? dictValue. mapKeys ( keys, valueTransform: valueTransform) {
302+ if let r = try ? dictValue. mapTransform ( keys, valueTransform: valueTransform) {
303303 // if so, lets recurse...
304304 newValue = r
305305 }
@@ -309,7 +309,7 @@ extension Dictionary where Key == String, Value == Any {
309309 newValue = arrayValue. map { item -> Value in
310310 var newValue = item
311311 if let dictValue = item as? [ Key : Value ] {
312- if let r = try ? dictValue. mapKeys ( keys, valueTransform: valueTransform) {
312+ if let r = try ? dictValue. mapTransform ( keys, valueTransform: valueTransform) {
313313 newValue = r
314314 }
315315 }
@@ -318,7 +318,7 @@ extension Dictionary where Key == String, Value == Any {
318318 }
319319
320320 if !( newValue is [ Key : Value ] ) , let transform = valueTransform {
321- // it's not a dictionary apply our transform.
321+ // it's not a dictionary so apply our transform.
322322
323323 // note: if it's an array, we've processed any dictionaries inside
324324 // already, but this gives the opportunity to apply a transform to the other
0 commit comments