{"id":13435086,"url":"https://github.com/msgpack/msgpack-erlang","last_synced_at":"2025-05-16T13:04:00.586Z","repository":{"id":45637484,"uuid":"2272904","full_name":"msgpack/msgpack-erlang","owner":"msgpack","description":"MessagePack (de)serializer implementation for Erlang / msgpack.org[Erlang]","archived":false,"fork":false,"pushed_at":"2023-09-23T12:42:52.000Z","size":2207,"stargazers_count":211,"open_issues_count":4,"forks_count":81,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-02T06:41:38.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://msgpack.org/","language":"Erlang","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/msgpack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-08-26T07:44:53.000Z","updated_at":"2025-03-25T07:05:18.000Z","dependencies_parsed_at":"2024-05-02T03:09:53.800Z","dependency_job_id":"c7522748-03b4-40a5-9139-8241e09116f5","html_url":"https://github.com/msgpack/msgpack-erlang","commit_stats":{"total_commits":264,"total_committers":21,"mean_commits":"12.571428571428571","dds":0.571969696969697,"last_synced_commit":"0dea2a4fd59a6e278f59bc0c65c2a654f4561e53"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msgpack%2Fmsgpack-erlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msgpack%2Fmsgpack-erlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msgpack%2Fmsgpack-erlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msgpack%2Fmsgpack-erlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msgpack","download_url":"https://codeload.github.com/msgpack/msgpack-erlang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999859,"owners_count":21031046,"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-07-31T03:00:32.286Z","updated_at":"2025-04-09T08:05:18.608Z","avatar_url":"https://github.com/msgpack.png","language":"Erlang","readme":"# MessagePack Erlang\n\n[![hex.pm version](https://img.shields.io/hexpm/v/msgpack.svg)](https://hex.pm/packages/msgpack)\n\n## Prerequisites for runtime\n\n[Erlang/OTP](http://erlang.org/), \u003e= 22.0 Also based on\n[the new msgpack spec 0b8f5a](https://github.com/msgpack/msgpack/blob/0b8f5ac67cdd130f4d4d4fe6afb839b989fdb86a/spec.md).\n\n## edit rebar.config to use in your application\n\n```erlang\n{deps, [\n  {msgpack, \".*\",\n    {git, \"git://github.com/msgpack/msgpack-erlang.git\", {branch, \"master\"}}}\n]}.\n```\n\nOr as it is [now published at hex.pm](https://hex.pm/packages/msgpack), just\n\n```erlang\n{deps, [msgpack]}.\n```\n\nmight work.\n\n## Simple deserialization\n\n```erlang\nHam = msgpack:pack(Spam),\n{ok, Spam} = msgpack:unpack(Ham).\n```\n\n## Stream deserialization\n\n```erlang\n{Term0, Rest0} = msgpack:unpack_stream(Binary),\n{Term1, Rest1} = msgpack:unpack_stream(Rest0),\n...\n```\n\n## Options, for packing and unpacking\n\n### `{spec, new|old}`\n\nBoth for packing and unpacking. Default is `new`. Major difference\nbetween old and new spec is:\n\n- raw family (`0xa0~0xbf`, `0xda`, `0xdb`) becomes new str family\n- `0xd9` is new as str8\n- new bin space (`0xc4, 0xc5, 0xc6` as bin8, bin16, bin32)\n- new ext space (`0xc7, 0xc8, 0xc9` as ext8, ext16, ext32)\n- new fixext space (`0xd4, 0xd5, 0xd6, 0xd7, 0xd8` as fixext1, fixext2, fixext4, fixext8, fixext16),\n\nThe default is new spec. Old spec mode does not handle these new types but\nreturns error. To use\n[old spec](https://github.com/msgpack/msgpack/blob/master/spec-old.md)\nmode, this option is explicitly added.\n\n```erlang\nOldHam = msgpack:pack(Spam, [{spec, old}]),\n{ok, Spam} = msgpack:unpack(OldHam, [{spec, old}]).\n```\n\n### `{allow_atom, none|pack}`\n\nOnly in packing. Atoms are packed as binaries. Default value is `pack`.\nOtherwise, any term including atoms throws badarg.\n\n### `{known_atoms, [atom()]}`\n\nBoth in packing and unpacking. In packing, if an atom is in this list\na binary is encoded as a binary. In unpacking, msgpacked binaries are\ndecoded as atoms with `erlang:binary_to_existing_atom/2` with encoding\n`utf8`. Default value is an empty list.\n\nEven if `allow_atom` is `none`, known atoms are packed.\n\n### `{unpack_str, as_binary|as_list}`\n\nA switch to choose decoded term style of `str` type when *unpacking*.\nOnly available at new spec. Default is `as_list`.\n\n```\nmode        as_binary    as_list\n-----------+------------+-------\nbin         binary()     binary()\nstr         binary()     string()\n```\n\n### `{use_nil, boolean()}`\n\nHandles Elixir `nil` as `null` Erlang atom. Default value is `false`.\n\n### `{validate_string, boolean()}`\n\nOnly in unpacking, UTF-8 validation at unpacking from `str` type will\nbe enabled. Default value is `false`.\n\n### `{pack_str, from_binary|from_list|none}`\n\nA switch to choose packing of `string()` when packing. Only available\nat new spec. Default is `from_list` for symmetry with `unpack_str`\noption.\n\n```\nmode        from_list    from_binary    none\n-----------+------------+--------------+-----------------\nbinary()    bin          str*/bin       bin\nstring()    str*/array   array of int   array of int\nlist()      array        array          array\n```\n\nBut the default option pays the cost of performance for symmetry. If\nthe overhead of UTF-8 validation is unacceptable, choosing `none` as\nthe option would be the best.\n\n- \\* Tries to pack as `str` if it is a valid `string()`.\n\n### `{map_format, map|jiffy|jsx}`\n\nBoth at packing and unpacking. Default value is `map`.\n\n```erlang\nmsgpack:pack(#{ \u003c\u003c\"key\"\u003e\u003e =\u003e \u003c\u003c\"value\"\u003e\u003e }, []).\nmsgpack:pack(#{ \u003c\u003c\"key\"\u003e\u003e =\u003e \u003c\u003c\"value\"\u003e\u003e }, [{map_format, map}]).\nmsgpack:pack({[{\u003c\u003c\"key\"\u003e\u003e, \u003c\u003c\"value\"\u003e\u003e}]}, [{map_format, jiffy}]),\nmsgpack:pack([{\u003c\u003c\"key\"\u003e\u003e, \u003c\u003c\"value\"\u003e\u003e}], [{map_format, jsx}]).\n```\n\n\n### `{ext, {msgpack_ext_packer(), msgpack_ext_unpacker()}|module()}`\n\nAt both. The default behaviour in case of facing ext data at decoding\nis to ignore them as its length is known.\n\nNow msgpack-erlang supports ext type. Now you can serialize everything\nwith your original (de)serializer. That will enable us to handle\nerlang- native types like `pid()`, `ref()` contained in `tuple()`. See\n`test/msgpack_ext_example_tests.erl` for example code.\n\n```erlang\nPacker = fun({ref, Ref}, Opt) when is_reference(Ref) -\u003e {ok, {12, term_to_binary(Ref)}} end,\nUnpacker = fun(12, Bin) -\u003e {ok, {ref, binary_to_term(Bin)}} end,\nRef = make_ref(),\nOpt = [{ext,{Packer,Unpacker}}],\n{ok, {ref, Ref}} = msgpack:unpack(msgpack:pack({ref, Ref}, Opt), Opt).\n```\n\n## Misc\n\n### Float type\n\nThe Float type of Message Pack represents IEEE 754 floating point number, so it includes Nan and Infinity.\nIn unpacking, msgpack-erlang returns `nan`, `positive_infinity` and `negative_infinity`.\n\n## License\n\nApache License 2.0\n\n# Release Notes\n\n## 0.7.0\n\n- Support `nan`, `positive_infinity` and `negative_infinity`\n\n## 0.6.0\n\n- Support OTP 19.0\n\n## 0.5.0\n\n- Renewed optional arguments to pack/unpack interface. This is\n  incompatible change from 0.4 series.\n\n## 0.4.0\n\n- Deprecate `nil`\n- Moved to rebar3\n- Promote default map unpacker as default format when OTP is \u003e= 17\n- Added QuickCheck tests\n- Since this version OTP older than R16B03-1 are no more supported\n\n## 0.3.5 / 0.3.4\n\n- 0.3 series will be the last versions that supports R16B or older\n  versions of OTP.\n- OTP 18.0 support\n- Promote default map unpacker as default format when OTP is \u003e= 18\n\n## 0.3.3\n\n- Add OTP 17 series to Travis-CI tests\n- Fix wrong numbering for ext types\n- Allow packing maps even when {format,map} is not set\n- Fix Dialyzer invalid contract warning\n- Proper use of null for jiffy-style encoding/decoding\n\n## 0.3.2\n\n- set back default style as jiffy\n- fix bugs around nil/null handling\n\n## 0.3.0\n\n- supports map new in 17.0\n- jiffy-style maps will be deprecated in near future\n- set default style as map\n\n## 0.2.8\n\n0.2 series works with OTP 17.0, R16, R15, and with MessagePack's new\nand old format. But does not support `map` type introduced in\nOTP 17.0.\n\nIt also supports JSX-compatible mode.\n","funding_links":[],"categories":["协议"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsgpack%2Fmsgpack-erlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsgpack%2Fmsgpack-erlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsgpack%2Fmsgpack-erlang/lists"}