JSONDecoder

extension JSONDecoder
  • Decodes a value of the given type for the given keypath from the JSON object.

    Throws

    An Error if the decoding process encounters an error.

    Declaration

    Swift

    public func decode<T>(_ type: T.Type, from data: Data, keyPath: String) throws -> T where T : Decodable

    Parameters

    type

    The type of value to decode.

    data

    The JSON object to decode.

    keyPath

    The key path of the decoded value is associated with.

    Return Value

    A decoded value of the requested type.