Decoder

struct Decoder
  • Decodes an array of Decodable types. Returns an empty array if the key is missing.

  • Parameters:

    • key: The JSON key to use.
    • json: The JSON to decode.
  • Returns

    The array of Decodable type. Empty if the key is missing.

    Declaration

    Swift

    public static func decodeArray<T>(key: String, json: JSON) -> [T] where T: Decodable

    Parameters

    key

    The JSON key to use.

    json

    The JSON to decode.

    Return Value

    The array of Decodable type. Empty if the key is missing.

  • Decodes a dictionary containing an array of types that conform to the ImageResources protocol, and the Decodable protocol.

  • Parameters:

    • key: key path to the ImageResources in the JSON.
    • json: JSON containing an array of encoded ImageResources.
  • Returns

    an dictionary containing an array of ImageResources.

    Declaration

    Swift

    public static func decodeImageResources<T: ImageResource>(key: String,
                                                json: JSON) -> [String: [T]]? where T: Decodable

    Parameters

    key

    key path to the ImageResources in the JSON.

    json

    JSON containing an array of encoded ImageResources.

    Return Value

    an dictionary containing an array of ImageResources.