# MessagePack for Serialization

**URL:** https://forum.heroiclabs.com/t/messagepack-for-serialization/421
**Category:** Game Design
**Created:** [December 30, 2019, 8:17pm UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421 "2019-12-30T20:17:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mohammed](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Mohammed](https://forum.heroiclabs.com/u/Mohammed)
#### Post date: [December 30, 2019, 8:17pm UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421/1 "2019-12-30T20:17:21Z")

</div>

Hi,

I am trying to use MessagePack ([MessagePack: It's like JSON. but fast and small.](https://msgpack.org/index.html)) for serialization rather than json

I am using Lua & Unity. Any one had experience using MessagePack with Lua ? and do you recommend using it.

---

<div class="post-metadata">

### Author: ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)
#### Post date: [December 30, 2019, 8:35pm UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421/2 "2019-12-30T20:35:01Z")

</div>

@Mohammed What MessagePack library do you want to use with Lua? The official one linked on the MessagePack website appears to be broken now.

Why do you want to use MessagePack? Do you have a specific game protocol you still want to create?

---

<div class="post-metadata">

### Author: ![Mohammed](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Mohammed](https://forum.heroiclabs.com/u/Mohammed)
#### Post date: [December 31, 2019, 4:51am UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421/3 "2019-12-31T04:51:44Z")

</div>

@novabyte  
I had some issues with TinyJson ([Nakama.TinyJson Parsing High Numbers Problem - #2 by novabyte](https://forum.heroiclabs.com/t/nakama-tinyjson-parsing-high-numbers-problem/420/2))  
So I was reading about methods to serialize data and MessagePack had a lot of benefits like speed, performance & data size  
So I checked it

There are two options for Lua on the site  
I tried

> **[GitHub - kieselsteini/msgpack: A MessagePack implementation for Lua 5.3/5.4 -...](https://github.com/kieselsteini/msgpack)**
>
> A MessagePack implementation for Lua 5.3/5.4 - msgpack.org\[Lua\] - GitHub - kieselsteini/msgpack: A MessagePack implementation for Lua 5.3/5.4 - msgpack.org\[Lua\]

but I had some issues on line 148

> local length = #elements // 2

Also tried the below link and encountered some problems

> **[src · master · François Perrad / lua-MessagePack · GitLab](https://framagit.org/fperrad/lua-MessagePack/tree/master/src)**
>
> a pure Lua implementation of msgpack.org\[Lua\]

I know this is not an issue related directly to Nakama but I though maybe someone used it and can share his knowledge. Also, maybe a good solution to be considered along with TinyJson.

---

<div class="post-metadata">

### Author: ![Mohammed](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Mohammed](https://forum.heroiclabs.com/u/Mohammed)
#### Post date: [December 31, 2019, 6:31am UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421/4 "2019-12-31T06:31:41Z")

</div>

@novabyte  
for

> **[kieselsteini/msgpack](https://github.com/kieselsteini/msgpack)**
>
> A MessagePack implementation for Lua 5.3 - msgpack.org\[Lua\] - kieselsteini/msgpack

  
its for Lua 5.3 & Nakama uses 5.1 that’s way // floor division is not recognized & string.pack & so on

---

<div class="post-metadata">

### Author: ![Mohammed](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Mohammed](https://forum.heroiclabs.com/u/Mohammed)
#### Post date: [January 27, 2020, 6:13am UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421/5 "2020-01-27T06:13:05Z")

</div>

Hey @novabyte

My question may seem naive, but is it difficult to upgrade Nakama to LUA 5.3 so we get more features with LUA.

---

<div class="post-metadata">

### Author: ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)
#### Post date: [January 28, 2020, 10:12am UTC](https://forum.heroiclabs.com/t/messagepack-for-serialization/421/6 "2020-01-28T10:12:28Z")

</div>

Upgrading to Lua 5.3 would not be trivial, and is not part of the immediate roadmap.

If you absolutely must use a feature that’s not possible with Lua 5.1 then the Go runtime might be worth considering instead - it would allow you to use any Go library or package you care to import.
