{"id":14975685,"url":"https://github.com/olaferlandsen/typescript-json-object-mapper","last_synced_at":"2025-10-27T14:31:12.585Z","repository":{"id":47036799,"uuid":"145856460","full_name":"olaferlandsen/Typescript-Json-Object-Mapper","owner":"olaferlandsen","description":"Json Object mapper writing in TypeScript","archived":false,"fork":false,"pushed_at":"2024-08-10T19:51:54.000Z","size":116,"stargazers_count":5,"open_issues_count":24,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-11T12:20:36.518Z","etag":null,"topics":["annotations","javascript","javascript-object","jom","js","json","json-objects","mapper","object-mapper","ts","typescript"],"latest_commit_sha":null,"homepage":"","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/olaferlandsen.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":"2018-08-23T13:20:16.000Z","updated_at":"2024-08-10T19:51:58.000Z","dependencies_parsed_at":"2024-06-21T03:16:22.652Z","dependency_job_id":"f04e9941-400a-47ca-bfba-289323084750","html_url":"https://github.com/olaferlandsen/Typescript-Json-Object-Mapper","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"2f49627a1134b299e4a5512a0378afd361c5e613"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2FTypescript-Json-Object-Mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2FTypescript-Json-Object-Mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2FTypescript-Json-Object-Mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaferlandsen%2FTypescript-Json-Object-Mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olaferlandsen","download_url":"https://codeload.github.com/olaferlandsen/Typescript-Json-Object-Mapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861084,"owners_count":16556007,"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":["annotations","javascript","javascript-object","jom","js","json","json-objects","mapper","object-mapper","ts","typescript"],"created_at":"2024-09-24T13:52:23.472Z","updated_at":"2025-10-27T14:31:07.244Z","avatar_url":"https://github.com/olaferlandsen.png","language":"TypeScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=HEF7696BDQTDG"],"categories":[],"sub_categories":[],"readme":"# (TypeScript) Json-Object-Mapper\n[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=HEF7696BDQTDG)\n\nThis a simple package to mapping a json object.\n\n\n## Getting Started\n### Install\n```bash\nnpm install typescript-json-object-mapper\n```\n```bash\nyarn add typescript-json-object-mapper\n```\n### Configure\nTo work with decorators, you need first enable `emitDecoratorMetadata` y `experimentalDecorators` on you `tsconfig.json`.\nExample:\n```json\n{\n    \"compilerOptions\": {\n        \"emitDecoratorMetadata\": true,\n        \"experimentalDecorators\": true\n    }\n}\n```\n### Create you own Views\nThis example tries to show all possible cases in which you might need to use this utility.\n\n```typescript\nclass UserView extends JsonView {\n    @JsonProperty\n    username: string;\n    \n    @JsonProperty({\n        ignore: true\n    })\n    password: string;\n    \n    @JsonProperty({\n        topic: 'custom'\n    })\n    birthday: string;\n    @JsonProperty({\n        topic: 'custom2'\n    })\n    phone: string;\n}\n```\n\n### Define you data object\n```typescript\nconst json = {\n    username: \"annon\",\n    password: \"12345678\",\n    birthday: \"1992-03-20\",\n    phone: \"+0123456789\"\n};\n```\n### Serilize(without topic's)\n```typescript\nconst serialized = JsonObjectMapper.serialize(json, UserView).toString();\n```\nresults:\n```json\n{\n    username: \"annon\",\n    birthday: \"1992-03-20\",\n    phone: \"+0123456789\"\n}\n```\n\n### Serilize(with topic)\n```typescript\nconst serialized = JsonObjectMapper.serialize(json, UserView, ['custom']).toString();\n```\nresults:\n```json\n{\n    username: \"annon\",\n    birthday: \"1992-03-20\"\n}\n```\n\n### Serilize(with topic)\n```typescript\nconst serialized = JsonObjectMapper.serialize(json, UserView, ['custom', 'custom2']).toString();\n```\nresults:\n```json\n{\n    username: \"annon\",\n    birthday: \"1992-03-20\",\n    phone: \"+0123456789\"\n}\n```\n\n## Features\n* [x] No-Initiation(Using only reference to class)\n* [x] Renaming properties\n* [x] Change data types\n    * [x] to Date\n        * [x] from String using `Date.parse`\n        * [x] from Integer using `Date`\n    * [x] to Integer\n        * [x] from String using `Number`\n    * [x] to Float\n        * [x] from String using `Number`\n    * [x] to Boolean\n    * [x] to String\n    * [x] to Object\n* [x] Sub-Views(Recursivity)\n    * [x] Array sub-views\n    * [x] Single sub-view\n* [x] Date values(String, Number, Date)\n* [x] Serialize from `Object Array`\n* [x] Serialize from `Object`\n* [x] Serialize from `String`\n* [x] Property Topic's\n\n## API:\n\n### JsonObjectMapper.serialize\nThis function always return `Serialization` object.\nAnd can using it with data as `Array` or `Object`.\n\n##### Example\n```typescript\n// from Array\nJsonObjectMapper.serialize([\n    {\n        email: \"john.smith@example.com\",\n        password: \"123456\"\n    },\n    {\n        email: \"john.smith@example.com\",\n        password: \"123456\"\n    },\n    {\n        email: \"john.smith@example.com\",\n        password: \"123456\"\n    }\n], UserView);\n\n// from Object\nJsonObjectMapper.serialize({\n   email: \"john.smith@example.com\",\n   password: \"123456\"\n}, UserView);\n```\n\n### Serialization\n#### Serialization.toString(`spaces:number = 4`): `string`\nThis method return a string representation of object.\n\n#### Serialization.toJson()\nThis method return a json object representation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaferlandsen%2Ftypescript-json-object-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folaferlandsen%2Ftypescript-json-object-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaferlandsen%2Ftypescript-json-object-mapper/lists"}