BSONDecoder

public class BSONDecoder

BSONDecoder facilitates the decoding of BSON into semantic Decodable types.

  • Enum representing the various strategies for decoding Dates from BSON.

    As per the BSON specification, the default strategy is to decode Dates from BSON datetime objects.

    See also

    bsonspec.org
    See more

    Declaration

    Swift

    public enum DateDecodingStrategy
  • Enum representing the various strategies for decoding UUIDs from BSON.

    As per the BSON specification, the default strategy is to decode UUIDs from BSON binary types with the UUID subtype.

    See also

    bsonspec.org
    See more

    Declaration

    Swift

    public enum UUIDDecodingStrategy
  • Enum representing the various strategies for decoding Datas from BSON.

    As per the BSON specification, the default strategy is to decode Datas from BSON binary types with the generic binary subtype.

    See also

    bsonspec.org
    See more

    Declaration

    Swift

    public enum DataDecodingStrategy
  • Contextual user-provided information for use during decoding.

    Declaration

    Swift

    public var userInfo: [CodingUserInfoKey : Any]
  • The strategy used for decoding Dates with this instance.

    Declaration

    Swift

    public var dateDecodingStrategy: DateDecodingStrategy
  • The strategy used for decoding UUIDs with this instance.

    Declaration

    Swift

    public var uuidDecodingStrategy: UUIDDecodingStrategy
  • The strategy used for decoding Datas with this instance.

    Declaration

    Swift

    public var dataDecodingStrategy: DataDecodingStrategy
  • Initializes self.

    Declaration

    Swift

    public init(options: CodingStrategyProvider? = nil)
  • Decodes a top-level value of the given type from the given BSON document.

    Throws

    DecodingError if any value throws an error during decoding.

    Declaration

    Swift

    public func decode<T>(_ type: T.Type, from document: BSONDocument) throws -> T where T : Decodable

    Parameters

    type

    The type of the value to decode.

    document

    The BSON document to decode from.

    Return Value

    A value of the requested type.

  • Decodes a top-level value of the given type from the given BSON data.

    Throws

    DecodingError if the BSON data is corrupt or if any value throws an error during decoding.

    Declaration

    Swift

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

    Parameters

    type

    The type of the value to decode.

    data

    The BSON data to decode from.

    Return Value

    A value of the requested type.

  • Decodes a top-level value of the given type from the given JSON/extended JSON string.

    Throws

    DecodingError if the JSON data is corrupt or if any value throws an error during decoding.

    Declaration

    Swift

    @available(*, deprecated, message: "Use ExtendedJSONDecoder.decode instead")
    public func decode<T>(_: T.Type, from json: String) throws -> T where T : Decodable

    Parameters

    type

    The type of the value to decode.

    json

    The JSON string to decode from.

    Return Value

    A value of the requested type.