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) throws

    Parameters

    map

    A filled map that represents the content of this object.

  • init(jsonString:encoding:) Extension method

    Initialize this object from a JSON String

    Throws

    Throws an error if the JSON string cannot be deserialized.

    Declaration

    Swift

    public init(jsonString: String, encoding: String.Encoding = .utf8) throws

    Parameters

    jsonString

    The JSON String that will be deserialized

    encoding

    The encoding used on the string

  • init(jsonData:encoding:) Extension method

    Initialize this object from a JSON String

    Throws

    Throws an error if the JSON string cannot be deserialized.

    Declaration

    Swift

    public init(jsonData: Data, encoding: String.Encoding = .utf8) throws

    Parameters

    jsonString

    The JSON String that will be deserialized

    encoding

    The encoding used on the string

  • init(json:) Extension method

    Initialize 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?]) throws

    Parameters

    jsonString

    The JSON String that will be deserialized

    encoding

    The encoding used on the string

  • Initialize an array of this object from a JSON String

    Throws

    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

    jsonString

    The JSON String that will be deserialized

    encoding

    The encoding used on the string

    failOnError

    When true, throws an exception if any object fails to parse. Otherwise the object is just removedfrom the list.

  • Initialize an array of this object from a JSON Data

    Throws

    Throws an error if the JSON string cannot be deserialized.

    Declaration

    Swift

    static func parseArray(jsonData: Data, failOnError: Bool = false) throws -> [Self]

    Parameters

    jsonString

    The JSON String that will be deserialized

    encoding

    The encoding used on the string

  • Initialize an array of this object from a JSON Data

    Throws

    Throws an error if the JSON string cannot be deserialized.

    Declaration

    Swift

    static func parseArray(json: [[String: Any?]], failOnError: Bool = false) throws -> [Self]

    Parameters

    jsonString

    The JSON String that will be deserialized

    encoding

    The encoding used on the string