{"id":15684274,"url":"https://github.com/andrykonchin/marshal-parser","last_synced_at":"2026-03-13T00:31:55.407Z","repository":{"id":151657324,"uuid":"624147641","full_name":"andrykonchin/marshal-parser","owner":"andrykonchin","description":"Parser of the Ruby Marshal format","archived":false,"fork":false,"pushed_at":"2024-12-17T22:02:41.000Z","size":141,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-12-11T19:42:23.647Z","etag":null,"topics":["marshal","parser","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrykonchin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-05T21:04:19.000Z","updated_at":"2024-12-17T22:02:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"d10135c9-c7fa-4eb5-b726-27c5c4fa1591","html_url":"https://github.com/andrykonchin/marshal-parser","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/andrykonchin/marshal-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrykonchin%2Fmarshal-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrykonchin%2Fmarshal-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrykonchin%2Fmarshal-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrykonchin%2Fmarshal-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrykonchin","download_url":"https://codeload.github.com/andrykonchin/marshal-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrykonchin%2Fmarshal-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30451551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T21:31:01.033Z","status":"ssl_error","status_checked_at":"2026-03-12T21:30:43.161Z","response_time":114,"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":["marshal","parser","ruby"],"created_at":"2024-10-03T17:13:56.120Z","updated_at":"2026-03-13T00:31:55.388Z","avatar_url":"https://github.com/andrykonchin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marshal-parser\n\n`marshal-parser` is a library that allows you to read and analyze data\nthat has been serialized in Ruby's Marshal format. It is built for\neducational purposes, but can also be a handy tool for learning the\nMarshal format or even for investigating bugs in its implementation.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'marshal-parser'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install marshal-parser\n\n## What is the Marshal format?\n\nThe Marshal format is a binary format used in Ruby to serialize Ruby\nobjects. The format can store arbitrary objects through three\nuser-defined extension mechanisms. The serialized data can be stored in\na file or transmitted over a network, and then deserialized back into a\nRuby object.\n\nThe Marshal format is described here \u003chttps://ruby-doc.org/core-3.1.0/doc/marshal_rdoc.html\u003e.\n\nThere are also a lot of articles that could be useful, for instance:\n- \u003chttps://shopify.engineering/caching-without-marshal-part-one\u003e\n- \u003chttps://iliabylich.github.io/2016/01/25/ruby-marshalling-from-a-to-z.html\u003e\n- \u003chttp://jakegoulding.com/blog/categories/marshal/\u003e\n\n## Features\n\nThere are a couple of uniq features that makes it stand out from the\ncroud:\n\n- comprehensive support of the Marshal format\n- CLI to parse existing dumps\n- several output formats with different detalization levels\n\n## Usage\n\nThe primary way to use `marshal-parser` is to run the CLI script `marshal-cli`.\n\n### Tokens\n\nTo print tokens separated by whitespaces, use the `tokens` command,\nfollowed by the `--evaluate` flag and a Ruby expression which value you\nwant to dump and parse:\n\n    marshal-cli tokens --evaluate '[true, false, 0]'\n\nThis will output:\n\n    \"\\x04\\b\" [ \"\\b\" T F i \"\\x00\"\n\nTo print descriptions for each token, use the `--annotate` flag:\n\n    marshal-cli tokens --evaluate '[true, false, 0]' --annotate\n\nThis will output:\n\n    \"\\x04\\b\"   - Version (4.8)\n    \"[\"        - Array beginning\n    \"\\b\"       - Integer encoded (3)\n    \"T\"        - true\n    \"F\"        - false\n    \"i\"        - Integer beginning\n    \"\\x00\"     - Integer encoded (0)\n\n### AST\n\nTo print the AST or structure of a Marshal dump, use the `ast` command,\nfollowed by the `--evaluate` flag:\n\n    marshal-cli ast --evaluate '[true, false, 0]'\n\nThis will output:\n\n    (array\n      (length 3)\n      (true)\n      (false)\n      (integer\n        (value 0)))\n\nThe AST is printed in a kind of S-expressions form. Both nodes (e.g. `array`,\n`integer`...) and attributes (`length`) are printed.\n\nTo print only the nodes, use the `--compact` flag:\n\n    marshal-cli --evaluate '[true, false, 0]' --compact\n\nThis will output:\n\n    (array\n      true\n      false\n      (integer 0))\n\nTo print the AST as tokens, use the `--only-tokens` option:\n\n    marshal-cli ast --evaluate '[true, false, 0]' --only-tokens\n\nThis will output:\n\n    [\n      \"\\b\"\n      T\n      F\n      i \"\\x00\"\n\n### Other flags\n\nTo list all the available flags use the `--help` flag for each command:\n\n    marshal-cli tokens --help\n    marshal-cli ast --help\n    marshal-cli --help\n\n### Ruby library\n\nTo use `marshal-parser` as a Ruby library the following examples will be\nuseful:\n\nUse `MarshalParser::Lexer` class to get tokens:\n\n```ruby\nrequire 'marshal-parser'\n\ndump = Marshal.dump(1)\nlexer = MarshalParser::Lexer.new(dump)\nlexer.run\n\npp lexer.tokens\n```\n\nThis will output:\n\n    [#\u003cstruct MarshalParser::Lexer::Token id=0, index=0, length=2, value=\"4.8\"\u003e,\n     #\u003cstruct MarshalParser::Lexer::Token id=14, index=2, length=1, value=nil\u003e,\n     #\u003cstruct MarshalParser::Lexer::Token id=25, index=3, length=1, value=1\u003e]\n\nUse `MarshalParser::Parser` class to get the AST:\n\n```ruby\nrequire 'marshal-parser'\n\ndump = Marshal.dump(1)\nlexer = MarshalParser::Lexer.new(dump)\nlexer.run\n\nparser = MarshalParser::Parser.new(lexer)\nast = parser.parse\n\npp ast\n```\n\nThis will output:\n\n    #\u003cMarshalParser::Parser::IntegerNode:0x000000010daba4d8\n     @prefix=#\u003cstruct MarshalParser::Lexer::Token id=14, index=2, length=1, value=nil\u003e,\n     @value=#\u003cstruct MarshalParser::Lexer::Token id=25, index=3, length=1, value=1\u003e\u003e\n\n## Limitations\n\n- Supports only the current Marshal format version (4.8)\n- Does not support a deprecated node 'M' (that represents 'Class or Module')\n- Does not support a 'd' node (Data object, that represents wrapped pointers from Ruby extensions)\n- Doesn't print in annotations object indices (because Ruby is not consistent here and object indices assigning order may\nvary depending on a class of a dumped object)\n\n## Similar projects\n\nThere are several projects that might be interesting as well:\n- \u003chttps://github.com/iliabylich/pure_ruby_marshal\u003e\n- \u003chttps://github.com/drbrain/marshal-structure\u003e\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/andrykonchin/marshal-parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/andrykonchin/marshal-parser/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the marshal-parser project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/andrykonchin/marshal-parser/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrykonchin%2Fmarshal-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrykonchin%2Fmarshal-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrykonchin%2Fmarshal-parser/lists"}