{"id":17498214,"url":"https://github.com/floriangosse/srlz","last_synced_at":"2026-02-19T10:32:35.909Z","repository":{"id":42723535,"uuid":"283555202","full_name":"floriangosse/srlz","owner":"floriangosse","description":"A small serialization library that can be adapted to your own needs.","archived":false,"fork":false,"pushed_at":"2024-06-16T13:11:06.000Z","size":142,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T14:01:18.345Z","etag":null,"topics":["convert","deserialization","javascript","json","serialization","transform"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/floriangosse.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","funding":".github/FUNDING.yml","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},"funding":{"github":"floriangosse","ko_fi":"floriangosse","custom":"https://www.paypal.com/donate/?hosted_button_id=YLA68J8UDEH6"}},"created_at":"2020-07-29T16:58:42.000Z","updated_at":"2023-05-26T07:23:43.000Z","dependencies_parsed_at":"2024-12-08T13:00:24.788Z","dependency_job_id":null,"html_url":"https://github.com/floriangosse/srlz","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.05555555555555558,"last_synced_commit":"9cb056b359847cd2419845e7c17fce1319c39fd6"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/floriangosse/srlz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangosse%2Fsrlz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangosse%2Fsrlz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangosse%2Fsrlz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangosse%2Fsrlz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floriangosse","download_url":"https://codeload.github.com/floriangosse/srlz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangosse%2Fsrlz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29609839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"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":["convert","deserialization","javascript","json","serialization","transform"],"created_at":"2024-10-19T16:10:44.753Z","updated_at":"2026-02-19T10:32:35.882Z","avatar_url":"https://github.com/floriangosse.png","language":"JavaScript","funding_links":["https://github.com/sponsors/floriangosse","https://ko-fi.com/floriangosse","https://www.paypal.com/donate/?hosted_button_id=YLA68J8UDEH6"],"categories":[],"sub_categories":[],"readme":"# srlz\n\n\u003e A small serialization library that can be adapted to your own needs.\n\n## API\n\n### `GenericSerializer`\n\nA generic serializer which returns the input value and is the base for every serializer implementation.\n\n\n### `ObjectSerializer`\n\nA serializer which serializes / deserializes values based on the configures fields and corresponding serializers.\n\nIn most cases the class has to be extends by a more specific serializer class which takes care about a specific object\ntype.\n\n#### fields\n\n*Instance member*\n\nType: `Object`\n\nEach key of the objects maps to a field name and each value to a field specification.\n\n##### Field specification\n\n* `serializer` (optional)\u003cbr\u003e\n    Type: `Class extends GenericSerializer`\u003cbr\u003e\n    Defines the serializer class which should be used for the field.\n* `required` (optional)\u003cbr\u003e\n    Type: `boolean`\u003cbr\u003e\n    Throws an error if the field is missing during deserialization.\n\n\n## Usage\n\n### Custom serializer\n\nCreates serializer which convers the given array to a string by using a configured seperator.\n\n```js\nimport { GenericSerializer } from 'srlz';\n// OR\nconst { GenericSerializer } = require('srlz');\n\nclass JoinedArraySerializer extends GenericSerializer {\n    separator = '||';\n\n    serialize(value) {\n        return value.join(this.separator);\n    }\n\n    deserialize(value) {\n        return value.splut(this.separator);\n    }\n}\n\nconst serializer = new JoinedArraySerializer();\nserializer.serialize([ 1, 2, 3, 4, 5 ]);\n// Output: '1||2||3||4||5'\n```\n\n### Custom object serializer\n\nConverts a person object into an object in which the skills are represented as string.\n\n```js\nimport { ObjectSerializer } from 'srlz';\n// OR\nconst { ObjectSerializer } = require('srlz');\n\nclass PersonSerializer extends ObjectSerializer {\n    fields = {\n        name: {},\n        skills: { serializer: JoinedArraySerializer }\n    }\n}\n\nconst serializer = new PersonSerializer();\nserializer.serialize({\n    name: 'John Doe',\n    skills: [ 'Javascript', 'Typescript' ]\n});\n// Output: {\n//   name: 'John Doe',\n//   skills: 'Javascript||Typescript'\n// }\n```\n\n### Complex example\n\nThis example shows how to create custom serializers and how a serialization for the non scalar type `Date` could look\nlike.\n\n```js\nconst { GenericSerializer, ObjectSerializer } = require('srlz');\n\nconst post = {\n    title: 'My Blog Title',\n    publishedAt: new Date('2020-08-01T09:30:00.000Z')\n};\n\nclass ISODateSerializer extends GenericSerializer {\n    serialize(value) {\n        return value.toISOString();\n    }\n\n    deserialize(value) {\n        return new Date(value);\n    }\n}\n\nclass PostSerializer extends ObjectSerializer {\n    fields = {\n        title: {},\n        publishedAt: { serializer: ISODateSerializer }\n    }\n}\n\nconst postSerializer = new PostSerializer();\npostSerializer.serialize(post);\n// Output: {\n//   title: 'My Blog Title',\n//   publishedAt: '2020-08-01T09:30:00.000Z'\n// }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloriangosse%2Fsrlz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloriangosse%2Fsrlz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloriangosse%2Fsrlz/lists"}