{"id":13660659,"url":"https://github.com/hyperloris/tyson","last_synced_at":"2025-03-17T13:31:22.518Z","repository":{"id":57117046,"uuid":"125765126","full_name":"hyperloris/tyson","owner":"hyperloris","description":"A TypeScript serialization/deserialization library to convert objects to/from JSON","archived":true,"fork":false,"pushed_at":"2023-02-09T12:06:59.000Z","size":1211,"stargazers_count":26,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T12:07:25.100Z","etag":null,"topics":["angular","converter","deserialization","javascript","json","nodejs","serialization","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/hyperloris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-03-18T20:33:22.000Z","updated_at":"2025-03-08T18:03:00.000Z","dependencies_parsed_at":"2023-02-18T02:30:53.536Z","dependency_job_id":null,"html_url":"https://github.com/hyperloris/tyson","commit_stats":{"total_commits":40,"total_committers":1,"mean_commits":40.0,"dds":0.0,"last_synced_commit":"b0e40086211a8cce14e466704b66da431194d259"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperloris%2Ftyson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperloris%2Ftyson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperloris%2Ftyson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperloris%2Ftyson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperloris","download_url":"https://codeload.github.com/hyperloris/tyson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244041506,"owners_count":20388252,"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":["angular","converter","deserialization","javascript","json","nodejs","serialization","typescript"],"created_at":"2024-08-02T05:01:24.259Z","updated_at":"2025-03-17T13:31:21.958Z","avatar_url":"https://github.com/hyperloris.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://imgur.com/W9211Go.png\" width=\"430\" /\u003e\n  \u003cdiv\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@hyperloris/tyson\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/v/@hyperloris/tyson.svg?style=flat-square\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://travis-ci.org/hyperloris/tyson\"\u003e\n      \u003cimg src=\"https://img.shields.io/travis/hyperloris/tyson/master.svg?style=flat-square\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/hyperloris/tyson/issues\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/issues/hyperloris/tyson.svg?style=flat-square\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/github/hyperloris/tyson?branch=master\"\u003e\n      \u003cimg src=\"https://img.shields.io/coveralls/github/hyperloris/tyson.svg?style=flat-square\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/hyperloris/tyson/blob/master/LICENSE\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/license/hyperloris/tyson.svg?style=flat-square\" /\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\n\u003e Tyson is a TypeScript serialization/deserialization library to convert objects to/from JSON.\n\n## Features\n\n* Simple `toJson()` and `fromJson()` methods for conversions\n* Many options on the property (e.g. custom naming, required and more)\n* Type-safe JSON deserialization\n* Support for multi-type arrays\n* Custom conversions through adapters and factories\n\n## Installation\n\nYou can install `tyson` using [npm](http://npmjs.org):\n\n```console\nnpm install --save @hyperloris/tyson\n```\n\n## Usage\n\nThe primary class to use is [`Tyson`](https://hyperloris.github.io/tyson/classes/tyson.html) which you can just create by calling `new Tyson()`. There is also a class [`TysonBuilder`](https://hyperloris.github.io/tyson/classes/tysonbuilder.html) available that can be used to create a Tyson instance with various settings (e.g. register a custom type adapter).\n\n### Requirements\n\nThere are three requirements to be met in order to make the library work properly:\n\n* Set experimentalDecorators and emitDecoratorMetadata to true on your `tsconfig.json` file\n* Properties need to be preceded by the [`@JsonProperty`](https://hyperloris.github.io/tyson/globals.html#jsonproperty) annotation\n* Properties need to have a default value (e.g. `undefined`)\n\n### A nice example\n\nLet's start with a JSON representing a city:\n\n```json\n{\n  \"name\": \"Bologna\",\n  \"population\": 388884,\n  \"monuments\": [\"Piazza Maggiore\", \"Palazzo Re Enzo\"],\n  \"mayor\": {\n    \"full_name\": \"Virginio Merola\",\n    \"birthdate\": \"1955-02-14T00:00:00\"\n  }\n}\n```\n\nNow we need a couple of TypeScript classes:\n\n```typescript\nexport class User {\n  @JsonProperty(\"full_name\")\n  name: string = undefined;\n  @JsonProperty({ type: Date })\n  birthdate: Date = undefined;\n}\n\nexport class City {\n  @JsonProperty()\n  name: string = undefined;\n  @JsonProperty()\n  population: number = undefined;\n  @JsonProperty({ name: \"monuments\", type: [String] })\n  private _monuments: string[] = undefined;\n  @JsonProperty(\"mayor\")\n  private _mayor: User = undefined;\n}\n```\n\nAt this point we are ready to use the library:\n\n```typescript\nconst tyson = new Tyson();\nconst city = tyson.fromJson(json, City);\nconst json = tyson.toJson(city);\n```\n\n## Documentation\n\nTyson [API](http://hyperloris.github.io/tyson): generated with [TypeDoc](http://typedoc.org) at every release.\n\n## Inspiration\n\nThe library is inspired by the [Gson](https://github.com/google/gson) library.\n\n## License\n\nMIT\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperloris%2Ftyson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperloris%2Ftyson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperloris%2Ftyson/lists"}