Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chronolaw/lua-resty-msgpack
Lua messagepack for ngx_lua/stream_lua/OpenResty
https://github.com/chronolaw/lua-resty-msgpack
messagepack ngx openresty
Last synced: 3 months ago
JSON representation
Lua messagepack for ngx_lua/stream_lua/OpenResty
- Host: GitHub
- URL: https://github.com/chronolaw/lua-resty-msgpack
- Owner: chronolaw
- License: mit
- Created: 2017-12-17T02:32:24.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T02:28:59.000Z (over 6 years ago)
- Last Synced: 2024-02-15T05:33:42.787Z (9 months ago)
- Topics: messagepack, ngx, openresty
- Language: Lua
- Homepage:
- Size: 16.6 KB
- Stars: 13
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-resty - lua-resty-msgpack
README
# lua-resty-msgpack
Lua messagepack for ngx_lua/stream_lua/OpenRestyThis is an opm wrapper for [lua-MessagePack](https://github.com/fperrad/lua-MessagePack.git)(But it is broken now)
Another choice is [luajit-msgpack-pure](https://github.com/catwell/luajit-msgpack-pure), but it has a different API.
## Installation
Please use `opm`, such as :
```lua
opm get chronolaw/lua-resty-msgpack
```## Usage
### Basics
```lua
local mp = require "resty.msgpack"local my_data = {this = {"is",4,"test"}}
local encoded = mp.pack(my_data)
local decoded = mp.unpack(encoded)
```### Concatenating encoded data
```lua
local mp = require "resty.msgpack"local my_data_1 = 42
local my_data_2 = "foo"
local encoded = mp.pack(my_data_1) .. mp.pack(my_data_2)for _,v in mp.unpacker(encoded) do
ngx.say("unpack is ", type(v), " : ", v)
end
```