Structures

The following structures are available globally.

  • A type-erased Codable value.

    The AnyCodable type forwards encoding and decoding responsibilities to an underlying value, hiding its specific underlying type.

    You can encode or decode mixed-type values in dictionaries and other collections that require Encodable or Decodable conformance by declaring their contained type to be AnyCodable.

    See also

    AnyEncodable

    See also

    AnyDecodable
    See more

    Declaration

    Swift

    @frozen
    struct AnyCodable
    extension AnyCodable : CustomDebugStringConvertible, CustomStringConvertible, Decodable, Encodable, Equatable, Equatable, ExpressibleByArrayLiteral, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, ExpressibleByNilLiteral, ExpressibleByStringInterpolation, ExpressibleByStringLiteral, ExpressibleByStringLiteral, ExpressibleByUnicodeScalarLiteral, ExpressibleByUnicodeScalarLiteral, Hashable, _AnyDecodable, _AnyEncodable
  • A type-erased Decodable value.

    The AnyDecodable type forwards decoding responsibilities to an underlying value, hiding its specific underlying type.

    You can decode mixed-type values in dictionaries and other collections that require Decodable conformance by declaring their contained type to be AnyDecodable:

    let json = """
    {
        "boolean": true,
        "integer": 42,
        "double": 3.141592653589793,
        "string": "string",
        "array": [1, 2, 3],
        "nested": {
            "a": "alpha",
            "b": "bravo",
            "c": "charlie"
        },
        "null": null
    }
    """.data(using: .utf8)!
    
    let decoder = JSONDecoder()
    let dictionary = try! decoder.decode([String: AnyDecodable].self, from: json)
    
    See more

    Declaration

    Swift

    @frozen
    struct AnyDecodable
    extension AnyDecodable : CustomDebugStringConvertible, CustomStringConvertible, Decodable, Equatable, Equatable, Hashable, _AnyDecodable
  • A type-erased Encodable value.

    The AnyEncodable type forwards encoding responsibilities to an underlying value, hiding its specific underlying type.

    You can encode mixed-type values in dictionaries and other collections that require Encodable conformance by declaring their contained type to be AnyEncodable:

    let dictionary: [String: AnyEncodable] = [
        "boolean": true,
        "integer": 42,
        "double": 3.141592653589793,
        "string": "string",
        "array": [1, 2, 3],
        "nested": [
            "a": "alpha",
            "b": "bravo",
            "c": "charlie"
        ],
        "null": nil
    ]
    
    let encoder = JSONEncoder()
    let json = try! encoder.encode(dictionary)
    
    See more

    Declaration

    Swift

    @frozen
    struct AnyEncodable
    extension AnyEncodable : CustomDebugStringConvertible, CustomStringConvertible, Encodable, Equatable, Equatable, ExpressibleByArrayLiteral, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, ExpressibleByNilLiteral, ExpressibleByStringInterpolation, ExpressibleByStringLiteral, ExpressibleByStringLiteral, ExpressibleByUnicodeScalarLiteral, ExpressibleByUnicodeScalarLiteral, Hashable, _AnyEncodable
  • LicenseSpring error.

    See more

    Declaration

    Swift

    struct LSError
    extension LSError : CustomNSError, Error, Error, Sendable, Sendable