测试已测试 | ✓ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布最后发布 | 2017 年 3 月 |
由 Paul Melnikow 维护。
依赖 | |
libbson | = 1.6.1-cocoapods-rc1 |
OrderedDictionary | ~> 1.2 |
Objective-C 中高性能的 BSON 序列化和反序列化。
ObjCBSON 通过 CocoaPods 提供。它依赖于 libbson,将自动安装,然而其两个构建依赖项并未。
首先,安装它们
brew install automake libtool
然后,将以下行添加到您的 Podfile
pod 'ObjCBSON'
#import "BSONSerialization.h"
- (void) bsonExample {
NSError *error = nil;
// BSON encode dictionary `sampleDict` to `NSData *` instance `bsonEncodedData`
NSDictionary *sampleDict = @{ @"sampleKey" : @"sampleValue" };
NSData *bsonEncodedData = [BSONSerialization BSONDataWithDictionary:sampleDict error:&error];
NSLog(@"bsonEncodedData=%@ error=%@", bsonEncodedData, [error localizedDescription]);
// ...end perform decording from BSON back to `NSDictionary *`
NSDictionary *bsonDict = [BSONSerialization dictionaryWithBSONData:bsonEncodedData error:&error];
NSLog(@"bsonDict=%@, error=%@", bsonDict, [error localizedDescription]);
}
要开发库并运行单元测试,请克隆仓库,从 Example 目录运行 pod install
,然后打开 xcworkspace。
项目采用 Apache 2.0 许可证。