Skip to content

forzafootball/msgpack-objc

Repository files navigation

msgpack-objc

An Objective-C wrapper for msgpack-c. Focuses on ease of use and speed. If you need configurability, there are other, more advanced libraries, for example MPMessagePack.

This library will always try to use sane defaults. If any nil value is encountered in the MessagePack-data, the object will be omitted instead of returning an [NSNull null]. This means that there can be no nil objects in dictionaries, and object-less keys will be lost in translation.

Example usage:

#import <msgpack-objc/MessagePack.h>

NSDictionary *dictionary = @{@"name": @"msgpack-objc"};

NSData *messagePackData = [MessagePack packObject:dictionary];
NSDictionary *unpackedDictionary = [MessagePack unpackData:messagePackData];

Supported native types:

  • NSArray
  • NSData
  • NSDate (using MessagePack timestamps)
  • NSDictionary
  • NSNumber (boolean, u64, i64, float32/64)
  • NSString

Extension support

The library supports MessagePack timestamps, and will return an NSDate-object whenever one is encountered. When serializing, any NSDate-objects will also be serialized as native MessagePack timestamps.

You can add native serialization for your own classes by conforming to protocol MessagePackSerializable and register it like this:

[MessagePack registerClass:Person.class forExtensionType:14];

About

An Objective-C wrapper for msgpack-c / msgpack.org[Objective-C]

Resources

License

Stars

Watchers

Forks

Packages

No packages published