AnyCodable

public struct AnyCodable: Codable

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
  • The type-erased underlying value.

    Declaration

    Swift

    public let value: Any
  • Declaration

    Swift

    public static func ==(lhs: AnyCodable, rhs: AnyCodable) -> Bool
  • A string representation of the codable object.

    Declaration

    Swift

    public var description: String
  • Returns a string that describes the contents of the receiver for presentation in the debugger.

    Declaration

    Swift

    public var debugDescription: String