File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Foundation
2
+ /// `ExtendedJSONDecoder` facilitates the decoding of ExtendedJSON into `Decodable` values.
3
+ public class ExtendedJSONDecoder {
4
+ /// Initialize an `ExtendedJSONDecoder`.
5
+ public init ( ) {
6
+ fatalError ( " unimplemented " )
7
+ }
8
+
9
+ /// Decodes an instance of the requested type `T` from the provided extended JSON data.
10
+ /// - SeeAlso: https://docs.mongodb.com/manual/reference/mongodb-extended-json/
11
+ ///
12
+ /// - Parameters:
13
+ /// - type: Codable type to decode the input into.
14
+ /// - data: `Data` which represents the JSON that will be decoded.
15
+ /// - Returns: Decoded representation of the JSON input as an instance of `T`.
16
+ /// - Throws: `DecodingError` if the JSON data is corrupt or if any value throws an error during decoding.
17
+ public func decode< T: Decodable > ( _ type: T . Type , from data: Data ) throws -> T {
18
+ // Takes in JSON as `Data` encoded with `.utf8` and runs it through a `JSONDecoder` to get an
19
+ // instance of the `JSON` enum. Then a `BSON` enum instance is created via the `JSON`.
20
+ // The `BSON` is then passed through a `BSONDecoder` where it is outputted as a `T`
21
+ // Data --> JSON --> BSON --> T
22
+ fatalError ( " unimplemented " )
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments