{"id":20837466,"url":"https://github.com/jd1378/the-serializer","last_synced_at":"2026-01-02T10:12:03.114Z","repository":{"id":255436476,"uuid":"850008880","full_name":"jd1378/the-serializer","owner":"jd1378","description":"a certain specific JSON stringifier ","archived":false,"fork":false,"pushed_at":"2024-09-01T06:11:12.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T05:20:00.491Z","etag":null,"topics":["bigint","javascript","serialize","serializer","serializers","symbol","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/the-serializer","language":"TypeScript","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/jd1378.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":"2024-08-30T17:31:56.000Z","updated_at":"2024-09-01T06:11:15.000Z","dependencies_parsed_at":"2024-08-31T00:15:48.066Z","dependency_job_id":"e9270fc3-d094-4fbd-be7b-63fb00bf94cb","html_url":"https://github.com/jd1378/the-serializer","commit_stats":null,"previous_names":["jd1378/the-serializer"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd1378%2Fthe-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd1378%2Fthe-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd1378%2Fthe-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd1378%2Fthe-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jd1378","download_url":"https://codeload.github.com/jd1378/the-serializer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655844,"owners_count":21943069,"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":["bigint","javascript","serialize","serializer","serializers","symbol","typescript"],"created_at":"2024-11-18T01:07:38.312Z","updated_at":"2026-01-02T10:12:03.083Z","avatar_url":"https://github.com/jd1378.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The serializer\n\na certain specific JSON stringifier that supports:\n\n- BigInt\n- Symbol\n- undefined\n- Infinity\n- Date\n- Map\n- Set\n- RegExp\n- URL\n\nand can possibly stringify your classes and revive them after parsing.\n\n## Usage\n\n```bash\npnpm install the-serializer\n```\n\n```ts\nimport {serialize, deserialize} from \"the-serializer\";\n\ndeserialize(serialize(BigInt(10))) === BigInt(10)\n\n// more advanced\n\n// to use class serialization and revival you need to implement `toJSON` and `fromJSON`\n// in your class, and pass your class to serialize and deserialize\n\nclass User {\n  constructor(\n    public name: string,\n    public age: number,\n  ) {}\n\n  toJSON() {\n    return serialize([this.name, this.age]);\n  }\n\n  static fromJSON(json: string) {\n    const [name, age] = deserialize(json);\n    // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n    return new User(name, age);\n  }\n}\n\nconst str = serialize(new User('john', 25), {User}); \n\nconsole.log(str); // '[\"{#$_C:User}[[\\\"1\\\",25],\\\"john\\\"]\"]'\n\nconst deserializedUser = deserialize(str, {User});\n\nconsole.log(deserializedUser instanceof User); // true\n```\n\n## Credits\n\nuses [flatted](https://www.npmjs.com/package/flatted) under the hood to handle circular references.\nsome ideas from [serialize-javascript](https://www.npmjs.com/package/serialize-javascript).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjd1378%2Fthe-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjd1378%2Fthe-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjd1378%2Fthe-serializer/lists"}