<commit_before># TUMessagePackSerialization

[![Version](http://cocoapod-badges.herokuapp.com/v/TUMessagePackSerialization/badge.png)](http://cocoadocs.org/docsets/TUMessagePackSerialization)
[![Platform](http://cocoapod-badges.herokuapp.com/p/TUMessagePackSerialization/badge.png)](http://cocoadocs.org/docsets/TUMessagePackSerialization)

## Usage

To run the tests project; clone the repo, and run `pod install` from the Project directory first.
<commit_msg>Added more info to the readme<commit_after># TUMessagePackSerialization for Objective-C

[![Version](http://cocoapod-badges.herokuapp.com/v/TUMessagePackSerialization/badge.png)](http://cocoadocs.org/docsets/TUMessagePackSerialization)
[![Platform](http://cocoapod-badges.herokuapp.com/p/TUMessagePackSerialization/badge.png)](http://cocoadocs.org/docsets/TUMessagePackSerialization)

[MessagePack: It's like JSON. but fast and small.](http://msgpack.org)

MessagePack is an awesome format and alternative to JSON that stores data in binary instead of plain text. For many languages, including Objective-C, the format that is stored is nearly identical to the raw format that is used by the language to store the data in memory and use it. Because of this, it should be much faster to decode and encode because in many cases you are just doing a memory copy from one place to another.

At least, that is the theory, when I started exploring using MessagePack on iOS, I found that the official ObjC library was actually *slower* than the built in `NSJSONSerialization`. In part, that is because Apple has done a really good job at optomizing their JSON parser, but I felt it should be faster. Here's some stats taken from various serialization options using samples of various api responses:

![Serialization stats](http://davbeck.s3.amazonaws.com/TUMessagePackSerialization-Stats.svg)

Note that I tried to get a comparison to [`plists`](https://en.wikipedia.org/wiki/Property_list), but they don't support `null`, which makes translating api results difficult. When I was able to get it to work, it was much slower than the other options.

## Usage

### Encoding objects as MessagePack data

```objc
NSError *error = nil;
NSData *result = [TUMessagePackSerialization dataWithMessagePackObject:value options:0 error:&error];
```

### Decoding MessagePack data as objects

```objc
NSError *error = nil;
id result = [TUMessagePackSerialization messagePackObjectWithData:example options:0 error:&error];
```

----

To run the tests project; clone the repo, and run `pod install` from the Project directory first.

{'fraction_non_alphanumeric': 0.09140412290937379, 'fraction_numerical': 0.0011668611435239206, 'mean_word_length': 5.561224489795919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7332739', 'n_tokens_mistral': 732, 'n_tokens_neox': 717, 'n_words': 274}