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 moreSee also
bsonspec.orgDeclaration
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 moreSee also
bsonspec.orgDeclaration
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 moreSee also
bsonspec.orgDeclaration
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
DecodingErrorif any value throws an error during decoding.Declaration
Swift
public func decode<T>(_ type: T.Type, from document: BSONDocument) throws -> T where T : DecodableParameters
typeThe type of the value to decode.
documentThe 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
DecodingErrorif 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 : DecodableParameters
typeThe type of the value to decode.
dataThe 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
DecodingErrorif 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 : DecodableParameters
typeThe type of the value to decode.
jsonThe JSON string to decode from.
Return Value
A value of the requested type.
View on GitHub
Install in Dash
BSONDecoder Class Reference