Home

Awesome

<p align="center" > <img src="banner.png" width=300px alt="SwiftLocation" title="SwiftLocation"> </p> <p align="center"><strong>It's like JSON, but faster!</strong></p>

Carthage compatible CI Status Version License Platform

What's this?

MessagePack is an efficient binary serialization format, which lets you exchange data among multiple languages like JSON, except that it's faster and smaller. Small integers are encoded into a single byte while typical short strings require only one extra byte in addition to the strings themselves.
You can read more about specs directly from the main web site.
Moreover it's made in pure Swift, no dependencies, lightweight & fully portable

Your Support

Hi fellow developer!
You know, maintaing and developing tools consumes resources and time. While I enjoy making them your support is foundamental to allow me continue its development.

If you are using SwiftLocation or any other of my creations please consider the following options:

Index

<a name="howto" />

How to use: one-shot pack & unpack

Both serialization and deseralization happens inside a Data object.

In order to pack one or more objects you need to create an empty Data instance and call pack by passing the object(s) you want to serialize. It's pretty easy, take a look here:

var data = Data()
do {
  let obj1 = "Hello World"
  let obj2 = 45.5
  let obj3: [AnyHashable:Any?] = [ "key_1" : "value test","key_2" : 4,"key_3" : true, otherHashableKey: "value1"]
  // Now you can pack your instances by passing them to pack function
  try data.pack(obj1,obj2,obj3)
} catch {
  print("Something went wrong while packing data: \(error)")
}

Deserializing data is pretty simple too, just call unpack function to an instance of Data with msgpack data:

let data: Data = // msgpack data...
do {
  let decodedObj: Any? = try data.unpack()
} catch {
  print("Something went wrong while unpacking data: \(error)")
}
<a name="supportedtypes" />

Supported Types

SwiftMsgPack supports the following Swift types:

The following limitations are specified by MsgPack specs format:

<a name="installation" />

Installation

You can install Swiftline using CocoaPods, carthage and Swift package manager

CocoaPods

use_frameworks!
pod 'SwiftMsgPack'

Carthage

github 'malcommac/SwiftMsgPack'

Swift Package Manager

Add swiftline as dependency in your Package.swift

import PackageDescription

let package = Package(name: "YourPackage",
  dependencies: [
    .Package(url: "https://github.com/malcommac/SwiftMsgPack.git", majorVersion: 0),
  ]
)
<a name="tests" />

Tests

SwiftMsgPack has an extensive coverage using XCTest. You can found a complete list of tests inside Tests/SwiftMsgPackTests folder. Tests can also be runned with XCode using the SwiftMsgPack project.

<a name="credits" />

Contributing

Copyright & Acknowledgements

SwiftLocation is currently owned and maintained by Daniele Margutti.
You can follow me on Twitter @danielemargutti.
My web site is https://www.danielemargutti.com

This software is licensed under MIT License.

Follow me on: