Mapper
public final class Mapper<N: BaseMappable>
The Mapper class provides methods for converting Model objects to JSON and methods for converting JSON to Model objects
-
Undocumented
Declaration
Swift
public var context: MapContext?
-
Undocumented
Declaration
Swift
public var shouldIncludeNilValues = false /// If this is set to true, toJSON output will include null values for any variables that are not set.
-
If this is set to true, toJSON output will include null values for any variables that are not set.
Declaration
Swift
public init(context: MapContext? = nil, shouldIncludeNilValues: Bool = false)
-
Maps a JSON object to an existing Mappable object if it is a JSON dictionary, or returns the passed object as is
Declaration
Swift
public func map(JSONObject: Any?, toObject object: N) -> N
-
Map a JSON string onto an existing object
Declaration
Swift
public func map(JSONString: String, toObject object: N) -> N
-
Maps a JSON dictionary to an existing object that conforms to Mappable. Usefull for those pesky objects that have crappy designated initializers like NSManagedObject
Declaration
Swift
public func map(JSON: [String: Any], toObject object: N) -> N
-
Map a JSON string to an object that conforms to Mappable
Declaration
Swift
public func map(JSONString: String) -> N?
-
Maps a JSON object to a Mappable object if it is a JSON dictionary or NSString, or returns nil.
Declaration
Swift
public func map(JSONObject: Any?) -> N?
-
Maps a JSON dictionary to an object that conforms to Mappable
Declaration
Swift
public func map(JSON: [String: Any]) -> N?
-
Maps a JSON array to an object that conforms to Mappable
Declaration
Swift
public func mapArray(JSONString: String) -> [N]?
-
Maps a JSON object to an array of Mappable objects if it is an array of JSON dictionary, or returns nil.
Declaration
Swift
public func mapArray(JSONObject: Any?) -> [N]?
-
Maps an array of JSON dictionary to an array of Mappable objects
Declaration
Swift
public func mapArray(JSONArray: [[String: Any]]) -> [N]?
-
Maps a JSON object to a dictionary of Mappable objects if it is a JSON dictionary of dictionaries, or returns nil.
Declaration
Swift
public func mapDictionary(JSONString: String) -> [String: N]?
-
Maps a JSON object to a dictionary of Mappable objects if it is a JSON dictionary of dictionaries, or returns nil.
Declaration
Swift
public func mapDictionary(JSONObject: Any?) -> [String: N]?
-
Maps a JSON dictionary of dictionaries to a dictionary of Mappable objects
Declaration
Swift
public func mapDictionary(JSON: [String: [String: Any]]) -> [String: N]?
-
Maps a JSON object to a dictionary of Mappable objects if it is a JSON dictionary of dictionaries, or returns nil.
Declaration
Swift
public func mapDictionary(JSONObject: Any?, toDictionary dictionary: [String: N]) -> [String: N]
-
Maps a JSON dictionary of dictionaries to an existing dictionary of Mappable objects
Declaration
Swift
public func mapDictionary(JSON: [String: [String: Any]], toDictionary dictionary: [String: N]) -> [String: N]
-
Maps a JSON object to a dictionary of arrays of Mappable objects
Declaration
Swift
public func mapDictionaryOfArrays(JSONObject: Any?) -> [String: [N]]?
-
Maps a JSON dictionary of arrays to a dictionary of arrays of Mappable objects
Declaration
Swift
public func mapDictionaryOfArrays(JSON: [String: [[String: Any]]]) -> [String: [N]]?
-
Maps an 2 dimentional array of JSON dictionaries to a 2 dimentional array of Mappable objects
Declaration
Swift
public func mapArrayOfArrays(JSONObject: Any?) -> [[N]]?
-
Convert a JSON String into a Dictionary
using NSJSONSerialization Declaration
Swift
public static func parseJSONStringIntoDictionary(JSONString: String) -> [String: Any]?
-
Convert a JSON String into an Object using NSJSONSerialization
Declaration
Swift
public static func parseJSONString(JSONString: String) -> Any?
-
Undocumented
Declaration
Swift
public func map(JSON: [String: Any]) throws -> N
-
Undocumented
Declaration
Swift
public func map(JSONString: String) throws -> N
-
Undocumented
Declaration
Swift
public func map(JSONObject: Any) throws -> N
-
Undocumented
Declaration
Swift
public func mapArray(JSONArray: [[String: Any]]) throws -> [N]
-
Undocumented
Declaration
Swift
public func mapArray(JSONString: String) throws -> [N]
-
Undocumented
Declaration
Swift
public func mapArray(JSONObject: Any) throws -> [N]
-
Undocumented
Declaration
Swift
public func mapDictionary(JSONString: String) throws -> [String: N]
-
Undocumented
Declaration
Swift
public func mapDictionary(JSONObject: Any?) throws -> [String: N]
-
Undocumented
Declaration
Swift
public func mapDictionary(JSON: [String: [String: Any]]) throws -> [String: N]
-
Undocumented
Declaration
Swift
public func mapDictionaryOfArrays(JSONObject: Any?) throws -> [String: [N]]
-
Undocumented
Declaration
Swift
public func mapDictionaryOfArrays(JSON: [String: [[String: Any]]]) throws -> [String: [N]]
-
Undocumented
Declaration
Swift
public func mapArrayOfArrays(JSONObject: Any?) throws -> [[N]]
-
Undocumented
Declaration
Swift
internal func mapOrFail(JSON: [String: Any]) throws -> N
-
Undocumented
Declaration
Swift
internal func mapOrFail(JSONString: String) throws -> N
-
Undocumented
Declaration
Swift
internal func mapOrFail(JSONObject: Any) throws -> N
-
Maps an object that conforms to Mappable to a JSON dictionary
Declaration
Swift
public func toJSON(_ object: N) -> [String: Any]
-
Maps an array of Objects to an array of JSON dictionaries [[String: Any]]
Declaration
Swift
public func toJSONArray(_ array: [N]) -> [[String: Any]]
-
Maps a dictionary of Objects that conform to Mappable to a JSON dictionary of dictionaries.
Declaration
Swift
public func toJSONDictionary(_ dictionary: [String: N]) -> [String: [String: Any]]
-
Maps a dictionary of Objects that conform to Mappable to a JSON dictionary of dictionaries.
Declaration
Swift
public func toJSONDictionaryOfArrays(_ dictionary: [String: [N]]) -> [String: [[String: Any]]]
-
Maps an Object to a JSON string with option of pretty formatting
Declaration
Swift
public func toJSONString(_ object: N, prettyPrint: Bool = false) -> String?
-
Maps an array of Objects to a JSON string with option of pretty formatting
Declaration
Swift
public func toJSONString(_ array: [N], prettyPrint: Bool = false) -> String?
-
Converts an Object to a JSON string with option of pretty formatting
Declaration
Swift
public static func toJSONString(_ JSONObject: Any, prettyPrint: Bool) -> String?
-
Converts an Object to JSON data with options
Declaration
Swift
public static func toJSONData(_ JSONObject: Any, options: JSONSerialization.WritingOptions) -> Data?
-
Maps a JSON array to an object that conforms to Mappable
Declaration
Swift
public func mapSet(JSONString: String) -> Set<N>?
-
Maps a JSON object to an Set of Mappable objects if it is an array of JSON dictionary, or returns nil.
Declaration
Swift
public func mapSet(JSONObject: Any?) -> Set<N>?
-
Maps an Set of JSON dictionary to an array of Mappable objects
Declaration
Swift
public func mapSet(JSONArray: [[String: Any]]) -> Set<N>
-
Maps a Set of Objects to a Set of JSON dictionaries [[String : Any]]
Declaration
Swift
public func toJSONSet(_ set: Set<N>) -> [[String: Any]]
-
Maps a set of Objects to a JSON string with option of pretty formatting
Declaration
Swift
public func toJSONString(_ set: Set<N>, prettyPrint: Bool = false) -> String?