MapDecodable
public protocol MapDecodable
A protocol that adds support of complex objects to be deserialized from a JSON object.
-
Initializes the object with the contents of a map
Declaration
Swift
init(map: Map) throwsParameters
mapA filled map that represents the content of this object.
-
init(jsonString:encoding:)Extension methodInitialize this object from a JSON
StringThrows
Throws an error if the JSON string cannot be deserialized.Declaration
Swift
public init(jsonString: String, encoding: String.Encoding = .utf8) throwsParameters
jsonStringThe JSON
Stringthat will be deserializedencodingThe encoding used on the string
-
init(jsonData:encoding:)Extension methodInitialize this object from a JSON
StringThrows
Throws an error if the JSON string cannot be deserialized.Declaration
Swift
public init(jsonData: Data, encoding: String.Encoding = .utf8) throwsParameters
jsonStringThe JSON
Stringthat will be deserializedencodingThe encoding used on the string
-
init(json:)Extension methodInitialize this object from a JSON Object
Throws
Throws an error if the JSON string cannot be deserialized.Declaration
Swift
public convenience init(json: [String : Any?]) throwsParameters
jsonStringThe JSON
Stringthat will be deserializedencodingThe encoding used on the string
-
parseArray(jsonString:encoding:failOnError:)Extension methodInitialize an array of this object from a JSON
StringThrows
Throws an error if the JSON string cannot be deserialized.Declaration
Swift
static func parseArray(jsonString: String, encoding: String.Encoding = .utf8, failOnError: Bool = false) throws -> [Self]Parameters
jsonStringThe JSON
Stringthat will be deserializedencodingThe encoding used on the string
failOnErrorWhen true, throws an exception if any object fails to parse. Otherwise the object is just removedfrom the list.
-
parseArray(jsonData:failOnError:)Extension methodInitialize an array of this object from a JSON
DataThrows
Throws an error if the JSON string cannot be deserialized.Declaration
Swift
static func parseArray(jsonData: Data, failOnError: Bool = false) throws -> [Self]Parameters
jsonStringThe JSON
Stringthat will be deserializedencodingThe encoding used on the string
-
parseArray(json:failOnError:)Extension methodInitialize an array of this object from a JSON
DataThrows
Throws an error if the JSON string cannot be deserialized.Declaration
Swift
static func parseArray(json: [[String: Any?]], failOnError: Bool = false) throws -> [Self]Parameters
jsonStringThe JSON
Stringthat will be deserializedencodingThe encoding used on the string
View on GitHub
MapDecodable Protocol Reference