#BSONKit
The BSONDecoder is an Objective-C framework for decoding binary JSON according to the BSON specification http://bsonspec.org
####Type conversion rules
BSON types are converted into Objective-C types according to the table below:
BSON type | Objective-c type |
---|---|
Document | NSDictionary |
Floating point | double |
UTF-8 string | NSString |
Array | NSArray |
Binary data | NSData |
ObjectId | NSData |
Boolean | BOOL |
UTC datestamp | long long |
Null value | NSNill |
Regular expression | NSArray with two objects - regexp pattern (NSString) and options (NSString) |
Javascript code | NSString |
Symbol | NSString |
Javascript code with scope | NSArray with two objects - the Javascript code (NSString) and scope variables (NSDictionary) |
32-bit integer | NSInteger |
Timestamp | long long |
64-bit integer | long long |
Min key | TBD |
Max key | TBD |
##Interface
The interface for performing the decoding is very simple:
// Get a decoder instance
+ (id)decoder;
// Start decoding a BSON byte array
- (id)decode:(NSData*)source withError:(NSError**)error;
There is also a convenience NSData category:
// Decoding a BSON byte array
- (id)decodeBSONWithError:(NSError**)error;