{"id":19885675,"url":"https://github.com/asmod4n/mruby-simplemsgpack","last_synced_at":"2026-01-25T12:10:03.154Z","repository":{"id":33966623,"uuid":"37702510","full_name":"Asmod4n/mruby-simplemsgpack","owner":"Asmod4n","description":"mruby wrapper for msgpack (\u003e= 1.0) / msgpack.org[mruby]","archived":false,"fork":false,"pushed_at":"2026-01-11T08:21:25.000Z","size":276,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-11T14:20:26.262Z","etag":null,"topics":["mruby","msgpack"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Asmod4n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-06-19T05:00:43.000Z","updated_at":"2026-01-11T08:20:29.000Z","dependencies_parsed_at":"2024-03-07T12:45:40.264Z","dependency_job_id":"84775809-a10e-43fd-ba8c-4b5b4b76c1d5","html_url":"https://github.com/Asmod4n/mruby-simplemsgpack","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Asmod4n/mruby-simplemsgpack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-simplemsgpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-simplemsgpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-simplemsgpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-simplemsgpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asmod4n","download_url":"https://codeload.github.com/Asmod4n/mruby-simplemsgpack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-simplemsgpack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28752693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T10:25:12.305Z","status":"ssl_error","status_checked_at":"2026-01-25T10:25:11.933Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["mruby","msgpack"],"created_at":"2024-11-12T17:35:16.187Z","updated_at":"2026-01-25T12:10:03.147Z","avatar_url":"https://github.com/Asmod4n.png","language":"C++","readme":"mruby-simplemsgpack\n===================\n\nBreaking changes\n================\n\nStarting with Version 4, Symbol packing changed, see Symbol Handling (Updated) down below.\n\nInstallation\n============\n\nFirst get a working copy of [mruby](https://github.com/mruby/mruby) then add\n\n```ruby\n  conf.gem mgem: 'mruby-simplemsgpack'\n```\n\nto the build_conf.rb of the mruby directory\n\nmruby-simplemsgpack searches for msgpack-c on your system, if it can find it it links against it, otherwise it builds against msgpack-c from source.\nYou need at least msgpack-c 1 and depending on your system also pkg-config.\n\nFor building from source you need to have cmake installed on your system, take a look at \u003chttps://github.com/msgpack/msgpack-c/blob/c_master/QUICKSTART-C.md#install-with-source-code\u003e for more information.\n\nExample\n-------\n\nObjects can be packed with `Object#to_msgpack` or `MessagePack.pack`:\n\n```ruby\npacked_hash = { a: 'hash', with: [1, 'embedded', 'array'] }.to_msgpack\npacked_string = MessagePack.pack('bye')\n\npacked_hash   # =\u003e \"\\x82\\xA1a\\xA4hash\\xA4with\\x93\\x01\\xA8embedded\\xA5array\"\npacked_string # =\u003e \"\\xA3bye\"\n```\n\nThey are unpacked with `MessagePack.unpack`:\n\n```ruby\nMessagePack.unpack(packed_hash)   # =\u003e { a: 'hash', with: [1, 'embedded', 'array'] }\nMessagePack.unpack(packed_string) # =\u003e 'bye'\n```\n\nA string with multiple packed values can be unpacked by handing a block to\n`MessagePack.unpack`:\n\n```ruby\npacked = packed_string + packed_hash\nunpacked = []\nMessagePack.unpack(packed) do |result|\n  unpacked \u003c\u003c result\nend\nunpacked # =\u003e ['bye', { a: 'hash', with: [1, 'embedded', 'array'] }]\n```\n\nWhen using `MessagePack.unpack` with a block and passing it a incomplete packed Message\nit returns the position of the first offending byte, if it was able to unpack the whole Message it returns self.\nThis is helpful if the given data contains an incomplete\nlast object and we want to continue unpacking after we have more data.\n\n```ruby\npacked = packed_string + packed_hash.slice(0, packed_hash.length/2)\nunpacked = []\noffending_byte = MessagePack.unpack(packed) do |result|\n  unpacked \u003c\u003c result\nend\noffending_byte # =\u003e 19 (length of packed)\nunpacked # =\u003e ['bye']\n```\n\n# Lazy unpacking\n\nNeed to pull just a few values from a large MessagePack payload?\n`MessagePack.unpack_lazy` can be up to **10× faster** because it avoids fully unpacking the structure — only the parts you ask for are decoded.\nIt returns a lightweight handle that lets you navigate using JSON Pointers:\n\n```ruby\ndata = [\n  { \"id\" =\u003e 1, \"name\" =\u003e \"Alpha\" },\n  { \"id\" =\u003e 2, \"name\" =\u003e \"Beta\" },\n  { \"id\" =\u003e 3, \"name\" =\u003e \"Gamma\" },\n  { \"id\" =\u003e 4, \"name\" =\u003e \"Delta\", \"meta\" =\u003e { \"active\" =\u003e true } }\n]\n\npacked = MessagePack.pack(data)\n\nlazy = MessagePack.unpack_lazy(packed)\n\n# Access an element by JSON Pointer without fully unpacking everything\nlazy.at_pointer(\"/3/name\")        # =\u003e \"Delta\"\nlazy.at_pointer(\"/3/meta/active\") # =\u003e true\nlazy.at_pointer(\"/3\")             # =\u003e { \"id\" =\u003e 4, \"name\" =\u003e \"Delta\", \"meta\" =\u003e { \"active\" =\u003e true } }\n\n# Root access (returns entire unpacked object)\nlazy.value  # =\u003e full data\n```\n## Error handling\n\nWhen using `MessagePack.unpack_lazy(...).at_pointer(pointer)`, specific exceptions are raised for invalid pointers or traversal mistakes:\n\n```ruby\ndata = [\n  { \"id\" =\u003e 1, \"name\" =\u003e \"Alpha\" },\n  { \"id\" =\u003e 2, \"name\" =\u003e \"Beta\" }\n]\n\nlazy = MessagePack.unpack_lazy(MessagePack.pack(data))\n\n# Non-existent array index\nlazy.at_pointer(\"/99/name\")\n# =\u003e IndexError (array index out of range)\n\n# Non-existent key in an object\nlazy.at_pointer(\"/0/nope\")\n# =\u003e KeyError (key not found)\n\n# Attempting to navigate into a scalar value\nlazy.at_pointer(\"/0/name/foo\")\n# =\u003e TypeError (cannot navigate into a string)\n```\n\nSymbol Handling (Updated)\n-------------------------\nMessagePack for mruby now provides a **built‑in, user‑configurable symbol packing strategy**.\nThis replaces the old pattern where users had to register extension types manually for symbols.\n\nYou can choose between three strategies:\n\n- **`:raw`** (default)\n  Symbols are packed as normal MessagePack strings.\n\n- **`:string`**\n  Symbols are packed as an extension type containing their string name.\n\n- **`:int`**\n  Symbols are packed as an extension type containing their internal symbol ID.\n\nConfigure the strategy globally:\n\n```ruby\n# Pack symbols as raw strings (default)\nMessagePack.sym_strategy(:raw)\n\n# Pack symbols as ext with their string name\nMessagePack.sym_strategy(:string, 1)\n\n# Pack symbols as ext with their integer ID\nMessagePack.sym_strategy(:int, 1)\n```\n\nExtension Types\n---------------\n\nTo customize how objects are packed, define an [extension type](https://github.com/msgpack/msgpack/blob/master/spec.md#types-extension-type).\n\n```ruby\ncls_ext_type = 1\nMessagePack.register_pack_type(cls_ext_type, Class) { |cls| cls.to_s }\nMessagePack.register_unpack_type(cls_ext_type) { |data| data.constantize }\nMessagePack.unpack(Object.to_msgpack) # =\u003e Object\n```\n\nFor nil, true, false, Integer, Float, String, Array and Hash a registered\next type is ignored. They are always packed according to the [MessagePack\nspecification](https://github.com/msgpack/msgpack/blob/master/spec.md).\n\nProc, blocks or lambas\n-----------------------\n\nIf you want to pack and unpack mruby blocks take a look at the [mruby-proc-irep-ext](https://github.com/Asmod4n/mruby-proc-irep-ext) gem, it can be registered like the other extension types\n\nOverriding `to_msgpack`\n---------------------\n\nIt's not supported to override `to_msgpack`, `MessagePack.pack` ignores it, same when that object is included in a Hash or Array.\nThis gem treats objects like ruby does, if you want to change the way your custom Class gets handled you can add `to_hash`, `to_ary`, `to_int` or `to_str` methods so it will be packed like a Hash, Array, Integer or String (in that order) then.\n\nAcknowledgements\n----------------\n\nThis is using code from \u003chttps://github.com/msgpack/msgpack-c\u003e\n\nCopyright (C) 2008-2015 FURUHASHI Sadayuki\n\n   Distributed under the Boost Software License, Version 1.0.\n   (See accompanying file LICENSE_1_0.txt or copy at\n   http://www.boost.org/LICENSE_1_0.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-simplemsgpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmod4n%2Fmruby-simplemsgpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-simplemsgpack/lists"}