All Projects → malcommac → Swiftmsgpack

malcommac / Swiftmsgpack

Licence: mit
💬 Fast & Lightweight MsgPack Serializer & Deserializer for Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftmsgpack

Ceras
Universal binary serializer for a wide variety of scenarios https://discord.gg/FGaCX4c
Stars: ✭ 374 (+192.19%)
Mutual labels:  serializer, msgpack, serialization
Messagepack Csharp
Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
Stars: ✭ 3,668 (+2765.63%)
Mutual labels:  serializer, msgpack, serialization
Lora Serialization
LoraWAN serialization/deserialization library for The Things Network
Stars: ✭ 120 (-6.25%)
Mutual labels:  serializer, serialization
Serializer Pack
A Symfony Pack for Symfony Serializer
Stars: ✭ 1,068 (+734.38%)
Mutual labels:  serializer, serialization
Msgpack11
A tiny MessagePack library for C++11 (msgpack.org[C++11])
Stars: ✭ 78 (-39.06%)
Mutual labels:  msgpack, serialization
Msgpack Rust
MessagePack implementation for Rust / msgpack.org[Rust]
Stars: ✭ 561 (+338.28%)
Mutual labels:  msgpack, serialization
Msgpack Cli
MessagePack implementation for Common Language Infrastructure / msgpack.org[C#]
Stars: ✭ 761 (+494.53%)
Mutual labels:  msgpack, serialization
Dictfier
Python library to convert/serialize class instances(Objects) both flat and nested into a dictionary data structure. It's very useful in converting Python Objects into JSON format
Stars: ✭ 67 (-47.66%)
Mutual labels:  serializer, serialization
Airframe
Essential Building Blocks for Scala
Stars: ✭ 442 (+245.31%)
Mutual labels:  msgpack, serialization
Msgpack4nim
MessagePack serializer/deserializer implementation for Nim / msgpack.org[Nim]
Stars: ✭ 89 (-30.47%)
Mutual labels:  serializer, msgpack
Msgpack Scala
MessagePack serializer implementation for Scala / msgpack.org[Scala]
Stars: ✭ 87 (-32.03%)
Mutual labels:  msgpack, serialization
Go
A high-performance 100% compatible drop-in replacement of "encoding/json"
Stars: ✭ 10,248 (+7906.25%)
Mutual labels:  serializer, serialization
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-10.94%)
Mutual labels:  serializer, serialization
Hprose Java
Hprose is a cross-language RPC. This project is Hprose 2.0 for Java
Stars: ✭ 542 (+323.44%)
Mutual labels:  serializer, serialization
Eminim
JSON serialization framework for Nim, works from a Stream directly to any type and back. Depends only on stdlib.
Stars: ✭ 32 (-75%)
Mutual labels:  serializer, serialization
Cpp Serializers
Benchmark comparing various data serialization libraries (thrift, protobuf etc.) for C++
Stars: ✭ 533 (+316.41%)
Mutual labels:  msgpack, serialization
Hprose Golang
Hprose is a cross-language RPC. This project is Hprose for Golang.
Stars: ✭ 1,143 (+792.97%)
Mutual labels:  serializer, serialization
Msgpack.php
A pure PHP implementation of the MessagePack serialization format / msgpack.org[PHP]
Stars: ✭ 327 (+155.47%)
Mutual labels:  msgpack, serialization
Msgpack
msgpack.org[Go] MessagePack encoding for Golang
Stars: ✭ 1,353 (+957.03%)
Mutual labels:  msgpack, serialization
Mini Yaml
Single header YAML 1.0 C++11 serializer/deserializer.
Stars: ✭ 79 (-38.28%)
Mutual labels:  serializer, serialization

SwiftLocation

It's like JSON, but faster!

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

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)")
}

Supported Types

SwiftMsgPack supports the following Swift types:

  • String
  • Data
  • Bool
  • nil
  • Numeric values: Int & UInt (UInt8,Int8,UInt16,Int16,UInt32,Int32,UInt64,Int64), Float and Double
  • Dictionaries ([AnyHashable:Any?])
  • Array ([Any?])

The following limitations are specified by MsgPack specs format:

  • a value of an Integer object is limited from -(2^63) upto (2^64)-1
  • maximum length of a Binary object is (2^32)-1
  • maximum byte size of a String object is (2^32)-1
  • String objects may contain invalid byte sequence and the behavior of a deserializer depends on the actual implementation when it received invalid byte sequence
    • Deserializers should provide functionality to get the original byte array so that applications can decide how to handle the object
  • maximum number of elements of an Array object is (2^32)-1
  • maximum number of key-value associations of a Map object is (2^32)-1

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),
  ]
)

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.

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

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:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].