{"id":13805285,"url":"https://github.com/j8r/crystalizer","last_synced_at":"2025-07-24T10:12:27.556Z","repository":{"id":47188342,"uuid":"266836417","full_name":"j8r/crystalizer","owner":"j8r","description":"(De)serialize any Crystal object - out of the box. Supports JSON, YAML and Byte format.","archived":false,"fork":false,"pushed_at":"2023-02-13T01:41:18.000Z","size":143,"stargazers_count":41,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T23:08:55.536Z","etag":null,"topics":["crystal-lang","json","serialization","yaml"],"latest_commit_sha":null,"homepage":"https://j8r.github.io/crystalizer","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j8r.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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-25T17:10:19.000Z","updated_at":"2025-02-02T13:57:57.000Z","dependencies_parsed_at":"2024-05-02T19:54:14.981Z","dependency_job_id":"76d6920c-21c6-4639-92ed-40c82c61d01b","html_url":"https://github.com/j8r/crystalizer","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j8r%2Fcrystalizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j8r%2Fcrystalizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j8r%2Fcrystalizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j8r%2Fcrystalizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j8r","download_url":"https://codeload.github.com/j8r/crystalizer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j8r%2Fcrystalizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259191685,"owners_count":22819392,"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":["crystal-lang","json","serialization","yaml"],"created_at":"2024-08-04T01:00:59.614Z","updated_at":"2025-06-11T03:32:11.134Z","avatar_url":"https://github.com/j8r.png","language":"Crystal","funding_links":[],"categories":["Data Formats"],"sub_categories":[],"readme":"# Crystalizer\n\n[![CI](https://github.com/j8r/crystalizer/workflows/CI/badge.svg)](https://github.com/j8r/crystalizer/actions?query=workflow%3ACI)\n[![Documentation](https://github.com/j8r/crystalizer/workflows/Documentation/badge.svg)](https://j8r.github.io/crystalizer)\n[![ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=flat-square)](https://en.wikipedia.org/wiki/ISC_license)\n\n[De]serialize any Crystal object - out of the box. Supports JSON, YAML and Byte format.\n\n## Features\n\n- [De]serialize anything, \"out-of-the-box\"\n- Advanced serialization with annotations, but **not required**\n- Shared annotations for all formats (JSON, YAML...)\n\nImplementation bonus: no monkey patching involved :) (no method pollution on objects)\n\n## Installation\n\nAdd the dependency to your `shard.yml`:\n\n```yaml\ndependencies:\n  crystalizer:\n    github: j8r/crystalizer\n```\n\n## Documentation\n\nhttps://j8r.github.io/crystalizer\n\n## Usage\n\n### Basic\n\n```crystal\nrequire \"crystalizer/json\"\nrequire \"crystalizer/yaml\"\n\nstruct Point\n  getter x : Int32\n  @[Crystalizer::Field(key: \"Y\")]\n  getter y : String\n\n  def initialize(@x, @y)\n  end\nend\n\npoint = Point.new 1, \"a\"\n\n{Crystalizer::YAML, Crystalizer::JSON}.each do |format|\n  puts format\n  string = format.serialize point\n  puts string\n  puts format.deserialize string, to: Point\nend\n```\n\nResult:\n```\nCrystalizer::YAML\n---\nx: 1\nY: a\nPoint(@x=1, @y=\"a\")\nCrystalizer::JSON\n{\n  \"x\": 1,\n  \"Y\": \"a\"\n}\nPoint(@x=1, @y=\"a\")\n```\n\n### Any\n\nParsing any type, and converting to JSON/YAML.\n\n```cr\nrequire \"crystalizer/json\"\nrequire \"crystalizer/yaml\"\n\nyaml_string = \u003c\u003c-E\none: 1\ntwo: 2\nsub:\n  ary:\n  - one\n  - 2\nE\n\nyaml_any = Crystalizer::YAML.parse yaml_string\nputs yaml_any\n\njson_string = Crystalizer::JSON.serialize yaml_any\nputs json_string\n\njson_any = Crystalizer::JSON.parse json_string\nputs Crystalizer::YAML.serialize json_any\n```\n\nResult:\n```yaml\n{\"one\" =\u003e 1, \"two\" =\u003e 2, \"sub\" =\u003e {\"ary\" =\u003e [\"one\", 2]}}\n{\n  \"one\": 1,\n  \"two\": 2,\n  \"sub\": {\n    \"ary\": [\n      \"one\",\n      2\n    ]\n  }\n}\n---\none: 1\ntwo: 2\nsub:\n  ary:\n  - one\n  - 2\n```\n\n### User-defined serialization\n\nAllows to define custom serialization and deserialization for a given type.\n\n```crystal\nstruct MyType\n  include Crystalizer::Type\n\n  def initialize(@i : Int32)\n  end\n\n  def self.deserialize(deserializer : Crystalizer::Deserializer)\n    new deserializer.deserialize to: Int32\n  end\n\n  def serialize(serializer : Crystalizer::Serializer) : Nil\n    serializer.serialize @i\n  end\nend\n```\n\n### Note\n\nAnnotations are similar to the stdlib's `Serializable`, but all features are not yet fully implemented.\n\n## License\n\nCopyright (c) 2020-2023 Julien Reichardt - ISC License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj8r%2Fcrystalizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj8r%2Fcrystalizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj8r%2Fcrystalizer/lists"}