     }
     return nil
   }
+}
+
+// MARK: private functions
+extension Serializer {
+  private static func serializeArray(array: [Any]) -> [AnyObject] {
+    var ret:[AnyObject] = []
+    for element in array {
+      if let obj = serializeObject(element) {
+        ret.append(obj)
+      }
+    }
+    return ret
+  }
+  
+  private static func serializeArray(array: NSArray) -> [AnyObject] {
+    var ret:[AnyObject] = []
+    for element in array {
+      if let obj = serializeObject(element) {
+        ret.append(obj)
+      }
+    }
+    return ret
+  }
+  
+  private static func serializeArray(array: NSSet) -> [AnyObject] {
+    var ret:[AnyObject] = []
+    for element in array {
+      if let obj = serializeObject(element) {
+        ret.append(obj)
+      }
+    }
+    return ret
+  }
+  
+  private static func serializeMap(map: [String: Any]) -> [String: AnyObject] {
+    var ret: [String: AnyObject] = [:]
+    for (key, value) in map {
+      if let value = serializeObject(value) {
+        ret[key] = value
+      }
+    }
+    return ret
+  }
+  
+  private static func serializeMap(map: [String: AnyObject]) -> [String: AnyObject] {
+    var ret: [String: AnyObject] = [:]
+    for (key, value) in map {
+      if let value = serializeObject(value) {
+        ret[key] = value
+      }
+    }
+    return ret
+  }
   
   private static func swiftClassFromString(className: NSString) -> AnyClass? {
     let appName: NSString = "ApiTests"

  
  private static func isList(a: Any) -> Bool {
    if let _ = a as? NSArray { return true }
    if let _ = a as? NSDictionary { return true }
    if let _ = a as? [String: Any] { return true }
    if let _ = a as? [String: AnyObject] { return true }
    if let _ = a as? NSSet { return true }
    return false
  }

    }
    if isList(a) {
      if let array = a as? NSArray {
        return serializeArray(array)
      } else if let array = a as? [Any] {
        return serializeArray(array)
      } else if let map = a as? [String: Any] {
        return serializeMap(map)
      } else if let map = a as? [String: AnyObject] { // for some reason, this doesn't match above
        return serializeMap(map)
      } else if let set = a as? NSSet {
        return serializeArray(set)
      }
    }
    
