{"id":16351416,"url":"https://github.com/gabbhack/deser","last_synced_at":"2025-07-21T07:33:42.312Z","repository":{"id":55061915,"uuid":"316540129","full_name":"gabbhack/deser","owner":"gabbhack","description":"Serde-like de/serialization library for Nim.","archived":false,"fork":false,"pushed_at":"2024-10-06T10:01:35.000Z","size":1435,"stargazers_count":22,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T16:19:03.910Z","etag":null,"topics":["deser","deserialization","deserializer","efficient","library","marshalling","nim","nim-lang","serialization","serializer"],"latest_commit_sha":null,"homepage":"https://gabbhack.github.io/deser/","language":"Nim","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/gabbhack.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-11-27T15:41:40.000Z","updated_at":"2025-01-24T23:31:28.000Z","dependencies_parsed_at":"2024-11-07T15:01:20.483Z","dependency_job_id":"5dc51274-163a-42fe-9150-c6c40cc329e1","html_url":"https://github.com/gabbhack/deser","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/gabbhack/deser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabbhack%2Fdeser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabbhack%2Fdeser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabbhack%2Fdeser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabbhack%2Fdeser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabbhack","download_url":"https://codeload.github.com/gabbhack/deser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabbhack%2Fdeser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266261311,"owners_count":23901290,"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":["deser","deserialization","deserializer","efficient","library","marshalling","nim","nim-lang","serialization","serializer"],"created_at":"2024-10-11T01:09:21.152Z","updated_at":"2025-07-21T07:33:42.291Z","avatar_url":"https://github.com/gabbhack.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deser [![nim-version-img]][nim-version]\r\n\r\n[nim-version]: https://nim-lang.org/blog/2021/10/19/version-160-released.html\r\n[nim-version-img]: https://img.shields.io/badge/Nim_-v1.6.0%2B-blue\r\n\r\n**Serde-like de/serialization library for Nim.**\r\n\r\n`nimble install deser`\r\n\r\n[Documentation](https://deser.nim.town)\r\n\r\n---\r\n\r\n\u003cdetails\u003e \r\n  \u003csummary\u003eMotivation\u003c/summary\u003e\r\nMany serializers have already been written for Nim. You can probably find at least two serializers for each format. \r\n\r\nThe problem is that each library's API and customization options are different. I can't declare an object with renamed or skipped fields once and change the data format with one line.\r\n\r\nAttempts to generalize the serializer were also made. However, I found only one library that is actively under development - [nim-serialization](https://github.com/status-im/nim-serialization). When installing the library downloaded a quarter of all libraries for Nim, so I did not try it.\r\n\r\nThus, there was no library for Nim that standardized the serialization process, so I wrote **deser**.\r\n\r\nAlso read:\r\n- [Standards](https://xkcd.com/927/)\r\n- [Not invented here](https://en.wikipedia.org/wiki/Not_invented_here)\r\n\u003c/details\u003e\r\n\r\n\r\n## Supported formats\r\n - JSON - [deser_json](https://github.com/gabbhack/deser_json)\r\n\r\nAlso read:\r\n- [How to make bindings](https://deser.nim.town/deser.html#how-to-make-bindings)\r\n\r\n\r\n## Example\r\n```nim\r\nimport std/[\r\n  options,\r\n  times\r\n]\r\n\r\nimport\r\n  deser,\r\n  deser_json\r\n\r\nproc fromTimestamp(deserializer: var auto): Time =\r\n  fromUnix(deserialize(int64, deserializer))\r\n\r\nproc toTimestamp(self: Time, serializer: var auto) =\r\n  serializer.serializeInt64(self.toUnix())\r\n\r\ntype\r\n  ChatType = enum\r\n    Private = \"private\"\r\n    Group = \"group\"\r\n\r\n  Chat {.renameAll(SnakeCase).} = object\r\n    id: int64\r\n    username {.skipSerializeIf(isNone).}: Option[string]\r\n    created {.serializeWith(toTimestamp), deserializeWith(fromTimestamp).}: Time\r\n\r\n    case kind {.renamed(\"type\").}: ChatType\r\n    of Private:\r\n      firstName: string\r\n      lastName {.skipSerializeIf(isNone).}: Option[string]\r\n      bio {.skipSerializeIf(isNone).}: Option[string]\r\n    of Group:\r\n      title: string\r\n\r\n# Use public to export deserialize or serialize procedures\r\n# false by default\r\nmakeSerializable(Chat, public=true)\r\nmakeDeserializable(Chat, public=true)\r\n\r\nconst\r\n  json = \"\"\"\r\n  {\r\n    \"id\": 123,\r\n    \"username\": \"gabbhack\",\r\n    \"created\": 1234567890,\r\n    \"type\": \"private\",\r\n    \"first_name\": \"Gabben\"\r\n  }\r\n  \"\"\"\r\n  chat = Chat(\r\n    id: 123,\r\n    username: some \"gabbhack\",\r\n    created: fromUnix(1234567890),\r\n    kind: Private,\r\n    firstName: \"Gabben\"\r\n  )\r\n\r\necho Chat.fromJson(json)\r\necho chat.toJson()\r\n```\r\n\r\nAlso read:\r\n- [Customize serialization process](https://deser.nim.town/deser.html#customize-serialization-process)\r\n\r\n## License\r\nLicensed under \u003ca href=\"LICENSE\"\u003eMIT license\u003c/a\u003e.\r\n\r\nDeser uses third-party libraries or other resources that may be\r\ndistributed under licenses different than the deser.\r\n\r\n\u003ca href=\"THIRD-PARTY-NOTICES.TXT\"\u003eTHIRD-PARTY-NOTICES.TXT\u003c/a\u003e\r\n\r\n\r\n## Acknowledgements\r\n- [serde.rs](https://serde.rs), for all the ideas I stole\r\n- [fusion/matching](https://github.com/nim-lang/fusion/blob/master/src/fusion/matching.nim), for making it easier to work with object variants\r\n- [anycase](https://github.com/epszaw/anycase)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabbhack%2Fdeser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabbhack%2Fdeser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabbhack%2Fdeser/lists"}