{"id":17492949,"url":"https://github.com/chugunov/to_struct","last_synced_at":"2025-04-10T20:40:38.627Z","repository":{"id":62430485,"uuid":"123888113","full_name":"chugunov/to_struct","owner":"chugunov","description":"Transforms map to struct","archived":false,"fork":false,"pushed_at":"2018-03-15T15:49:32.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T15:09:55.029Z","etag":null,"topics":["elixir","map","struct"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/chugunov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-05T08:25:05.000Z","updated_at":"2022-01-12T20:12:01.000Z","dependencies_parsed_at":"2022-11-01T20:30:42.790Z","dependency_job_id":null,"html_url":"https://github.com/chugunov/to_struct","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chugunov%2Fto_struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chugunov%2Fto_struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chugunov%2Fto_struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chugunov%2Fto_struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chugunov","download_url":"https://codeload.github.com/chugunov/to_struct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248292333,"owners_count":21079419,"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":["elixir","map","struct"],"created_at":"2024-10-19T11:08:14.979Z","updated_at":"2025-04-10T20:40:38.605Z","avatar_url":"https://github.com/chugunov.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToStruct\n\n[![Build Status](https://api.travis-ci.org/chugunov/to_struct.svg?branch=master)](https://travis-ci.org/chugunov/to_struct)\n[![Hex.pm](https://img.shields.io/hexpm/v/to_struct.svg)](https://hex.pm/packages/to_struct)\n\nPackage helps you transform maps (ex. external data) to structs (internal data).\n\n## Example\n\nDefine a structs:\n\n```elixir\ndefmodule Product do\n  defstruct name: nil\nend\n\ndefmodule Cart do\n  defstruct id: nil,\n    products: nil\nend\n```\n\nDefine a transformation schema and then transform a map:\n\n```elixir\ndef to_struct() do\n  map = %{\n    \"id\" =\u003e 1,\n    \"products\" =\u003e [\n      %{\n        \"name\" =\u003e \"milk\"\n      },\n      %{\n        \"name\" =\u003e \"potato\",\n      }\n    ]\n  }\n\n  schema = %Cart{\n    products: [%Product{}],\n  }\n\n  ToStruct.transform(schema, map)\nend\n```\n\nResult: \n\n```elixir\n %Cart{\n  id: 1,\n  products: [\n    %Product{name: \"milk\"},\n    %Product{name: \"potato\"}\n  ]\n }\n```\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:to_struct, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchugunov%2Fto_struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchugunov%2Fto_struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchugunov%2Fto_struct/lists"}