{"id":13578262,"url":"https://github.com/antirez/lua-cmsgpack","last_synced_at":"2025-04-05T16:32:08.097Z","repository":{"id":2511031,"uuid":"3486465","full_name":"antirez/lua-cmsgpack","owner":"antirez","description":"A self contained Lua MessagePack C implementation.","archived":false,"fork":false,"pushed_at":"2021-12-28T19:18:31.000Z","size":95,"stargazers_count":355,"open_issues_count":33,"forks_count":118,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-11-05T15:49:46.754Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antirez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-19T16:19:27.000Z","updated_at":"2024-09-04T09:57:14.000Z","dependencies_parsed_at":"2022-09-07T03:11:29.995Z","dependency_job_id":null,"html_url":"https://github.com/antirez/lua-cmsgpack","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antirez%2Flua-cmsgpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antirez%2Flua-cmsgpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antirez%2Flua-cmsgpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antirez%2Flua-cmsgpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antirez","download_url":"https://codeload.github.com/antirez/lua-cmsgpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247366513,"owners_count":20927527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:28.883Z","updated_at":"2025-04-05T16:32:07.043Z","avatar_url":"https://github.com/antirez.png","language":"C","funding_links":[],"categories":["C","资源","Resources"],"sub_categories":["Parsing and Serialization"],"readme":"README for lua-cmsgpack.c\n===\n\nLua-cmsgpack is a [MessagePack](http://msgpack.org) implementation and bindings for\nLua 5.1/5.2/5.3 in a self contained C file without external dependencies.\n\nThis library is open source software licensed under the BSD two-clause license.\n\nINSTALLATION\n---\n\nUsing LuaRocks (http://luarocks.org):\n\n* Install current stable release:\n\n    sudo luarocks install lua-cmsgpack\n\n* Install current Git master head from GitHub:\n\n    sudo luarocks install lua-cmsgpack --from=rocks-cvs\n\n* Install from current working copy\n\n    cd lua-cmsgpack/\n    sudo luarocks make rockspec/lua-cmsgpack-scm-1.rockspec\n\nIf you embed Lua and all modules into your C project, just add the\n`lua_cmsgpack.c` file and call the following function after creating the Lua\ninterpreter:\n\n    luaopen_cmsgpack(L);\n\nUSAGE\n---\n\nThe exported API is very simple, consisting of four functions:\n\nBasic API:\n\n    msgpack = cmsgpack.pack(lua_object1, lua_object2, ..., lua_objectN)\n    lua_object1, lua_object2, ..., lua_objectN = cmsgpack.unpack(msgpack)\n\nDetailed API giving you more control over unpacking multiple values:\n\n    resume_offset, lua_object1 = cmsgpack.unpack_one(msgpack)\n    resume_offset1, lua_object2 = cmsgpack.unpack_one(msgpack, resume_offset)\n    ...\n    -1, lua_objectN = cmsgpack.unpack_one(msgpack, resume_offset_previous)\n\n    resume_offset, lua_object1, lua_object2 = cmsgpack.unpack_limit(msgpack, 2)\n    resume_offset2, lua_object3 = cmsgpack.unpack_limit(msgpack, 1, resume_offset1)\n\nFunctions:\n\n  - `pack(arg1, arg2, ..., argn)` - pack any number of lua objects into one msgpack stream.  returns: msgpack\n  - `unpack(msgpack)` - unpack all objects in msgpack to individual return values. returns: object1, object2, ..., objectN\n  - `unpack_one(msgpack); unpack_one(msgpack, offset)` - unpacks the first object after offset. returns: offset, object\n  - `unpack_limit(msgpack, limit); unpack_limit(msgpack, limit, offset)` - unpacks the first `limit` objects and returns: offset, object1, objet2, ..., objectN (up to limit, but may return fewer than limit if not that many objects remain to be unpacked)\n\nWhen you reach the end of your input stream with `unpack_one` or `unpack_limit`, an offset of `-1` is returned.\n\nYou may `require \"msgpack\"` or you may `require \"msgpack.safe\"`.  The safe version returns errors as (nil, errstring).\n\nHowever because of the nature of Lua numerical and table type a few behavior\nof the library must be well understood to avoid problems:\n\n* A table is converted into a MessagePack array type only if *all* the keys are\ncomposed of incrementing integers starting at 1 end ending at N, without holes,\nwithout additional non numerical keys. All the other tables are converted into\nmaps.\n* An empty table is always converted into a MessagePack array, the rationale is that empty lists are much more common than empty maps (usually used to represent objects with fields).\n* A Lua number is converted into an integer type if floor(number) == number, otherwise it is converted into the MessagePack float or double value.\n* When a Lua number is converted to float or double, the former is preferred if there is no loss of precision compared to the double representation.\n* When a MessagePack big integer (64 bit) is converted to a Lua number it is possible that the resulting number will not represent the original number but just an approximation. This is unavoidable because the Lua numerical type is usually a double precision floating point type.\n\nTESTING\n---\n\nBuild and test:\n\n    mkdir build; cd build\n    cmake ..\n    make\n    lua ../test.lua\n\nYou can build a 32-bit module on a 64-bit platform with:\n\n    mkdir build; cd build\n    cmake -DBuild32Bit=ON ..\n    make\n    lua ../test.lua\n\nNESTED TABLES\n---\nNested tables are handled correctly up to `LUACMSGPACK_MAX_NESTING` levels of\nnesting (that is set to 16 by default).\nEvery table that is nested at a greater level than the maxium is encoded\nas MessagePack nil value.\n\nIt is worth to note that in Lua it is possible to create tables that mutually\nrefer to each other, creating a cycle. For example:\n\n    a = {x=nil,y=5}\n    b = {x=a}\n    a['x'] = b\n\nThis condition will simply make the encoder reach the max level of nesting,\nthus avoiding an infinite loop.\n\nCREDITS\n---\n\nThis library was written by Salvatore Sanfilippo for Redis, but is maintained as a separated project by the author.\n\nSome of the test vectors in \"test.lua\" are obtained from the Javascript [MessagePack-JS library](https://github.com/cuzic/MessagePack-JS).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantirez%2Flua-cmsgpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantirez%2Flua-cmsgpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantirez%2Flua-cmsgpack/lists"}