MsgPackSerialization
MsgPackSerialization
遵循Foundation的NSJSONSerialization
类API约定,在Objective-C对象和MsgPack数据之间进行编码和解码。
使用方法
id obj = @{
@"foo": @(42.0),
@"bar": @"lorem ipsum",
@"baz": @[@1, @2, @3, @4]
};
NSError *error = nil;
CFAbsoluteTime t_0 = CFAbsoluteTimeGetCurrent();
NSData *data = [MsgPackSerialization dataWithMsgPackObject:obj options:0 error:&error];
NSLog(@"Packed: %@ (Elapsed: %g)", data, CFAbsoluteTimeGetCurrent() - t_0);
CFAbsoluteTime t_1 = CFAbsoluteTimeGetCurrent();
NSLog(@"Unpacked: %@ (Elapsed: %g)", [MsgPackSerialization MsgPackObjectWithData:data options:0 error:&error], CFAbsoluteTimeGetCurrent() - t_1);
联系方式
许可协议
MsgPackSerialization遵循MIT许可协议。更多信息请参阅LICENSE文件。