{"id":25687087,"url":"https://github.com/holyshared/serializer","last_synced_at":"2026-06-13T12:34:10.482Z","repository":{"id":136708213,"uuid":"2265919","full_name":"holyshared/Serializer","owner":"holyshared","description":"The object of the defined type is restored from the character string and the character string to the object with Type.","archived":false,"fork":false,"pushed_at":"2011-09-25T13:16:18.000Z","size":244,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T13:45:19.406Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/holyshared.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-25T04:04:39.000Z","updated_at":"2013-01-04T03:04:26.000Z","dependencies_parsed_at":"2023-03-10T22:11:04.394Z","dependency_job_id":null,"html_url":"https://github.com/holyshared/Serializer","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/holyshared%2FSerializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2FSerializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2FSerializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2FSerializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/holyshared","download_url":"https://codeload.github.com/holyshared/Serializer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240549397,"owners_count":19819139,"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":[],"created_at":"2025-02-24T20:08:07.144Z","updated_at":"2026-06-13T12:34:05.445Z","avatar_url":"https://github.com/holyshared.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nSerializer\n====================================\n\n![Serializer](http://holyshared.github.com/Serializer/seralizer.jpg)\n\nThe object of the defined type is restored from the character string and the character string to the object with Type.  \n\nHow to use\n------------------------------------\n\n### Definition of data type\n\nA new data type is defined by using **Type**. \nThe User type is defined in the following example.\n\n\tfunction User(name, email){\n\t\tthis.name = name;\n\t\tthis.email = email;\n\t}\n\n\tUser.prototype = {\n\t\tgetName: function(){\n\t\t\treturn this.name;\n\t\t},\n\t\n\t\tgetEmail: function(){\n\t\t\treturn this.email;\n\t\t}\n\t};\n\n\tnew Type('User', User);\n\n### The type is registered in a Serializer.\n\nThe data type and the conversion rule are specified for the argument. \nThe restoration from the character string uses and restores the regular expression.\n\n\t//Register user\n\tSerializer.register(User, {\n\t\n\t\tpaturn: '{name}={email}', //It is {name} and {email} placeholder.\n\t\n\t\tparams: {\n\t\t\tname: '\\\\w+',\n\t\t\temail: '\\\\w+'\n\t\t},\n\n\t\tserialize: function(object){\n\t\t\treturn this.assemble({\n\t\t        name: object.name,\n\t\t        email: object.email\n\t        });\n\t\t},\n\t\n\t\tdeserialize: function(params){\n\t\t\treturn new User(params.name, params.user);\n\t\t}\n\t\n\t});\n\n### It actually uses it. \n\nIt converts into the character string with **serialize**, and it converts it from the character string into the object with **deserialize**.  \nIt is possible to convert it from the character string into the object from the object to the character string by this freely.  \n\n\t//It converts it from the object to the character string. \n\tvar user = new User('username', 'user-email');\n\t\n\tvar serializer = new Serializer();\n\tvar source = serializer.serialize(user); //Return username=user-email\n\t\n\t//It restores it from the character string to the object.\n\tvar user = serializer.deserialize(source); //Return user object\n\tconsole.log(user.getName()); //Character string username is output. \n\tconsole.log(user.getEmail()); //Character string user-email is output. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fserializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholyshared%2Fserializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fserializer/lists"}