{"id":21971783,"url":"https://github.com/cristopher1/json-serializer-core","last_synced_at":"2026-04-28T23:03:27.634Z","repository":{"id":195285554,"uuid":"690221183","full_name":"cristopher1/json-serializer-core","owner":"cristopher1","description":"Wrapper to use JSON.parse and JSON.stringify methods, based on serializers","archived":false,"fork":false,"pushed_at":"2023-10-28T01:57:53.000Z","size":636,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-23T02:17:12.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@cljimenez/json-serializer-core","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/cristopher1.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":"2023-09-11T19:14:09.000Z","updated_at":"2023-11-06T17:01:34.000Z","dependencies_parsed_at":"2023-10-15T03:14:16.042Z","dependency_job_id":"7ba49ef7-976e-4651-ae85-1e57904b4ce8","html_url":"https://github.com/cristopher1/json-serializer-core","commit_stats":null,"previous_names":["cristopher1/json-serializer-core"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cristopher1/json-serializer-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fjson-serializer-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fjson-serializer-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fjson-serializer-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fjson-serializer-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristopher1","download_url":"https://codeload.github.com/cristopher1/json-serializer-core/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristopher1%2Fjson-serializer-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32402673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: 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":[],"created_at":"2024-11-29T14:55:50.936Z","updated_at":"2026-04-28T23:03:27.607Z","avatar_url":"https://github.com/cristopher1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eWelcome to @cljimenez/json-serializer-core 👋\u003c/h1\u003e\n\u003cp\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.2-blue.svg?cacheSeconds=2592000\" /\u003e\n  \u003ca href=\"https://github.com/cristopher1/json-serializer#readme\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/cristopher1/json-serializer/graphs/commit-activity\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/cristopher1/json-serializer/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/cristopher1/json-serializer-core\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Wrapper to use JSON.parse and JSON.stringify methods, based on serializers\n\n### 🏠 [Homepage](https://github.com/cristopher1/json-serializer#readme)\n\n### [Index](#index)\n\n- [Install](#install)\n- [What is a Serializer?](#what-is-a-serializer?)\n- [How to use?](#how-to-use?)\n  - [ Obtain the JsonSerializer object](#obtain-json-serializer-object)\n  - [ About the JsonSerializer methods](#about-json-serializer-methods)\n    - [1. getSerializerType](#get-serializer-type)\n    - [2. installSerializersAndRefreshJsonSerializer](#install-serializers)\n    - [3. addSerializerAndRefreshJsonSerializer](#add-serializer)\n    - [4. serialize](#serialize)\n    - [5. parse](#parse)\n  - [Serializes and unserializes complex object that contains objects created by the new operator](#complex-object-with-new-operator)\n- [Author](#author)\n- [Contributing](#contributing)\n- [License](#license)\n\n## \u003ca id=\"install\"\u003e\u003c/a\u003e Install\n\n```sh\nnpm install @cljimenez/json-serializer-core\n```\n\n**If you want to use some base serializers, you can use [@cljimenez/json-serializer-base-serializers](https://www.npmjs.com/package/@cljimenez/json-serializer-base-serializers?activeTab=readme)**\n\n## \u003ca id=\"what-is-a-serializer?\"\u003e\u003c/a\u003e What is a Serializer?\n\nA Serializer is an object that contains three methods:\n\n- **getSerializerType(void)=\u003estring**: Returns the type of serializer, for example: A serializer that serializes `functions` (FunctionSerializer) must return the string `'function'`. The type returned by this method can be one of the following:\n\n  1. Some value returned by **typeof operator**: `'array'`, `'function'`, `'bigint'`, `'string'`, `'object'`, etc.\n\n     Example:\n\n     ```js\n     const myFunction = (arg1, arg2) =\u003e `${arg1} and ${arg2}`\n\n     // Create the serializer\n\n     const functionSerializer = {\n       getSerializerType: () =\u003e 'function',\n       serialize: (unserializedData) =\u003e {\n         /* returns serialized data */\n       },\n       parse: (serializedData) =\u003e {\n         /* returns unserialized data */\n       },\n     }\n\n     /* Using class */\n     class FunctionSerializer {\n       /* you can to define constructor, other methods, etc */\n\n       getSerializerType() {\n         return 'function'\n       }\n\n       serialize(unserializedData) {\n         /* returns serialized data */\n       }\n\n       parse(serializedData) {\n         /* returns unserialized data */\n       }\n     }\n\n     const serializer = new FunctionSerializer(/* call using some parameters */)\n     ```\n\n  2. **If the serializer serializes an object**. getSerializerType method must return a value obtained by property **Object.constructor.name**, for example: if you creates a class called `MyOwnClass`, the getSerializerType method of MyOwnClassSerializer must return the string `'MyOwnClass'`, this is equivalent to use `new MyOwnClass().constructor.name`.\n\n     Example:\n\n     ```js\n     class MyClassToSerialize {\n       // Some implementation\n     }\n\n     // Create the serializer\n\n     /* Using object literal */\n     const myClassToSerializeSerializer = {\n       getSerializerType: () =\u003e 'MyClassToSerialize',\n       serialize: (unserializedData) =\u003e {\n         /* returns serialized data */\n       },\n       parse: (serializedData) =\u003e {\n         /* returns unserialized data */\n       },\n     }\n\n     /* Using class */\n     class MyClassToSerializeSerializer {\n       /* you can to define constructor, other methods, etc */\n\n       getSerializerType() {\n         return 'MyClassToSerialize'\n       }\n\n       serialize(unserializedData) {\n         /* returns serialized data */\n       }\n\n       parse(serializedData) {\n         /* returns unserialized data */\n       }\n     }\n\n     const serializer =\n       new MyClassToSerializeSerializer(/* call using some parameters */)\n     ```\n\n- **serialize(unserializedData: any) =\u003e object**: Serializes the data. Returns an object literal.\n- **parse(serializedData: object)=\u003eany**: Unserializes the data serialized by serialize method. The serializedData parameter contains the value returned by serialize method.\n\nAn example of complete serializer is:\n\n```js\nconst dateSerializer = {\n  getSerializerType: () =\u003e 'Date',\n  serialize: (unserializedData) =\u003e ({\n    value: unserializedData.toJSON()\n  })\n  // serializedData contains the value returned by serialize method.\n  parse: (serializedData) =\u003e {\n    const serializedDate = serializedData.value\n    return new Date(serializedDate)\n  }\n}\n```\n\n**Note**:\n\n1. In general, serialize method will return an object literal with an attribute that contains some object literal or some value supported by JSON.stringify and the parse method will receive that object into the serializedData parameter.\n\n2. You can use any structure to define the object literal returned by serialize method.\n\n3. When to add a serializer into JsonSerializer object, that serializer is saved in an object literal in the following way:\n\n   - The **`key`** is the value returned by **`getSerializerType`** method.\n\n   - The **`value`** is the serializer object.\n\n   **For that reasons the serializers can be overrides when are added into JsonSerializer object. It is only necessary to return the same value in the `getSerializerType` method**\n\n## \u003ca id=\"how-to-use?\"\u003e\u003c/a\u003e How to use?\n\n- ### \u003ca id=\"obtain-json-serializer-object\"\u003e\u003c/a\u003e Obtain the JsonSerializer object\n\n  **The `@cljimenez/json-serializer-core` package contains a class `JsonSerializerFactory` that is used to obtain a new `JsonSerializer` object**.\n\n  Example for commonjs:\n\n  ```js\n  const jsonSerializerCore = require('@cljimenez/json-serializer-core')\n  const jsonSerializer =\n    jsonSerializerCore.JsonSerializerFactory.createJsonSerializer()\n  ```\n\n  Example for ES Modules:\n\n  ```js\n  import { JsonSerializerFactory } from '@cljimenez/json-serializer-core'\n  const jsonSerializer = JsonSerializerFactory.createJsonSerializer()\n  ```\n\n- ### \u003ca id=\"about-json-serializer-methods\"\u003e\u003c/a\u003e About the JsonSerializer methods\n\n  The `JsonSerializer` object is a wrapper to use the methods JSON.stringify and JSON.parse with the replacer and reviver parameters. The `JsonSerializer` object contains five methods:\n\n  1. \u003ca id=\"get-serializer-type\"\u003e\u003c/a\u003e **getSerializers(void) =\u003e object**: Returns an object literal that contains all serializers added to the JsonSerializer object.\n\n     Example:\n\n     ```js\n     const jsonSerializer = JsonSerializerFactory.createJsonSerializer()\n\n     // add a FunctionSerializer\n     // add a DateSerializer\n\n     /*\n       Returns\n       {\n         'function': FunctionSerializer,\n         'Date': DateSerializer,\n       }\n      */\n     jsonSerializer.getSerializers()\n     ```\n\n     The keys `function` and `Date` are obtained from getSerializerType method.\n\n  2. \u003ca id=\"install-serializers\"\u003e\u003c/a\u003e **installSerializersAndRefreshJsonSerializer(serializerInstaller: { install: (serializerHandler: serializerHandler, installOptions?: object) =\u003e void }, installOptions: object)=\u003evoid**: Install serializers using an installer object and installOptions object that by default is an empty object, if a serializer already exists by a specific data type (both getSerializerType methods returns the same value), this serializer will be override. SerializerHandler is an object used to manage the serializers, this object exposes the methods getSerializers and addSerializer.\n\n     Example:\n\n     ```js\n     // serializerInstaller\n     const installer = {\n       install: (serializerHandler, installOptions) =\u003e {\n         const options = {\n           excludeSetSerializer: true,\n           ...installOptions,\n         }\n\n         const bigIntSerializer = {\n           getSerializerType: () =\u003e 'bigint',\n           serialize: (unserializedData) =\u003e ({\n             value: unserializedData.toString(),\n           }),\n           parse: (serializedData) =\u003e {\n             const { value } = serializedData\n             return BigInt(value)\n           },\n         }\n\n         const setSerializer = {\n           getSerializerType: () =\u003e 'Set',\n           serialize: (unserializedData) =\u003e ({\n             value: Array.from(unserializedData),\n           }),\n           parse: (serializedData) =\u003e {\n             const { value } = serializedData\n             return new Set(value)\n           },\n         }\n\n         serializerHandler.addSerializer(bigIntSerializer)\n         if (!options.excludeSetSerializer) {\n           serializerHandler.addSerializer(setSerializer)\n         }\n       },\n     }\n\n     // without using the installOptions parameter\n     const jsonSerializer = JsonSerializerFactory.createJsonSerializer()\n     jsonSerializer.installSerializersAndRefreshJsonSerializer(installer)\n\n     /*\n       {\n         bigint: {\n           getSerializerType: [Function: getSerializerType],\n           serialize: [Function: serialize],\n           parse: [Function: parse]\n         }\n       }\n      */\n     console.log(jsonSerializer.getSerializers())\n\n     // using the installOptions parameter\n     const newJsonSerializer = JsonSerializerFactory.createJsonSerializer()\n     newJsonSerializer.installSerializersAndRefreshJsonSerializer(installer, {\n       excludeSetSerializer: false,\n     })\n\n     /*\n        {                                                                                                                                         \n          bigint: {\n            getSerializerType: [Function: getSerializerType],\n            serialize: [Function: serialize],\n            parse: [Function: parse]\n          },\n          Set: {\n            getSerializerType: [Function: getSerializerType],\n            serialize: [Function: serialize],\n            parse: [Function: parse]\n          }\n        }\n       */\n     console.log(newJsonSerializer.getSerializers())\n     ```\n\n  3. \u003ca id=\"add-serializer\"\u003e\u003c/a\u003e **addSerializerAndRefreshJsonSerializer(serializer: Serializer) =\u003e void**: Adds a serializer, if a serializer already exists by a specific data type (both getSerializerType methods returns the same value), this serializer will be override.\n\n     Example:\n\n     ```js\n     const bigIntSerializer = {\n       getSerializerType: () =\u003e 'bigint',\n       serialize: (unserializedData) =\u003e ({\n         value: unserializedData.toString(),\n       }),\n       parse: (serializedData) =\u003e {\n         const { value } = serializedData\n         return BigInt(value)\n       },\n     }\n\n     const jsonSerializer = JsonSerializerFactory.createJsonSerializer()\n\n     // adds a Serializer\n     jsonSerializer.addSerializerAndRefreshJsonSerializer(bigIntSerializer)\n\n     // overrides a Serializer. How both serializers serializes bigInt (its getSerializerType methods returns the same value), the second serializer overrides the first serializer.\n     const newBigIntSerializer = {\n       getSerializerType: () =\u003e 'bigint',\n       serialize: (unserializedData) =\u003e ({\n         value: unserializedData.toString(),\n       }),\n       parse: (serializedData) =\u003e {\n         const { value } = serializedData\n         console.log(value)\n         return BigInt(value)\n       },\n     }\n\n     jsonSerializer.addSerializerAndRefreshJsonSerializer(newBigIntSerializer)\n     ```\n\n  4. \u003ca id=\"serialize\"\u003e\u003c/a\u003e **serialize(unserializedData: any, space?: string | int) =\u003e string**: This method calls the JSON.stringify method with replacer parameter, the space parameter is used to insert while space into output JSON string for readability purposes. Returns a JSON string.\n\n     Example:\n\n     ```js\n     const bigIntSerializer = {\n       getSerializerType: () =\u003e 'bigint',\n       serialize: (unserializedData) =\u003e ({\n         value: unserializedData.toString(),\n       }),\n       parse: (serializedData) =\u003e {\n         const { value } = serializedData\n         return BigInt(value)\n       },\n     }\n\n     const bigInt = BigInt(20000)\n\n     const jsonSerializer = JsonSerializerFactory.createJsonSerializer()\n\n     jsonSerializer.addSerializerAndRefreshJsonSerializer(bigIntSerializer)\n\n     // {\"__typeof__\":\"bigint\",\"value\":\"20000\"}\n     console.log(jsonSerializer.serialize(bigInt))\n\n     // string\n     console.log(typeof jsonSerializer.serialize(bigInt))\n     ```\n\n     **Note**:\n\n     1. When there is not a serializer to serialize data, it will be used the JSON.stringify algorithm to serialize the data.\n     2. When a serializer serializes data, this serializer adds the `__typeof__` property to the returned serialized object. The `__typeof__` property is used to call to the appropiate serializer to unserialize data.\n\n  5. \u003ca id=\"parse\"\u003e\u003c/a\u003e **parse(serializedData : string) =\u003e any**: This method calls the JSON.parse method with reviver parameter, the serializedData is a valid JSON string. Returns the parsed object.\n\n     Example:\n\n     ```js\n     const bigIntSerializer = {\n       getSerializerType: () =\u003e 'bigint',\n       serialize: (unserializedData) =\u003e ({\n         value: unserializedData.toString(),\n       }),\n       parse: (serializedData) =\u003e {\n         const { value } = serializedData\n         return BigInt(value)\n       },\n     }\n\n     const bigInt = BigInt(20000)\n\n     const jsonSerializer = JsonSerializerFactory.createJsonSerializer()\n\n     jsonSerializer.addSerializerAndRefreshJsonSerializer(bigIntSerializer)\n\n     const serializedData = jsonSerializer.serialize(bigInt)\n\n     // {\"__typeof__\":\"bigint\",\"value\":\"20000\"}\n     console.log(serializedData)\n\n     // string\n     console.log(typeof serializedData)\n\n     const unserializedData = jsonSerializer.parse(serializedData)\n\n     // 20000n\n     console.log(unserializedData)\n\n     // bigint\n     console.log(typeof unserializedData)\n     ```\n\n- ### \u003ca id=\"complex-object-with-new-operator\"\u003e\u003c/a\u003e Serializes and unserializes complex object that contains objects created by the new operator.\n\n  When you creates an object using the **`new`** operator, it is necessary to add to the class some method that returns an object literal representation, for example:\n\n  ```js\n  class MyOwnClass {\n    constructor(element1, element2) {\n      this.element1 = element1\n      this.element2 = element2\n    }\n\n    // It is not necessary to call this method same toObjectLiteral, it can have other name.\n    toObjectLiteral() {\n      return {\n        element1: this.element1,\n        element2: this.element2,\n      }\n    }\n  }\n  ```\n\n  The object literal must have all elements to recreate the original object.\n\n  **Note: It is possible that you needs to use Object.values() or other methods into parse method, when you recreates the original object using destructuring data (...data). See the parse method in the following example.**\n\n  An Example for this case, it is the tests used in the json-serializer-core repository:\n\n  ```js\n  export const getSerializer = (\n    getSerializerTypeFunc,\n    serializeFunc,\n    parseFunc,\n  ) =\u003e ({\n    getSerializerType: getSerializerTypeFunc,\n    serialize: serializeFunc,\n    parse: parseFunc,\n  })\n\n  class AirplaneTestClass {\n    #model\n\n    constructor(model) {\n      this.#model = model\n    }\n\n    getModel() {\n      return this.#model\n    }\n\n    getObjectLiteral() {\n      return {\n        model: this.#model,\n      }\n    }\n  }\n\n  class WheelTestClass {\n    #duration\n\n    constructor(duration) {\n      this.#duration = duration\n    }\n\n    getDuration() {\n      return this.#duration\n    }\n\n    getObjectLiteral() {\n      return {\n        duration: this.#duration,\n      }\n    }\n  }\n\n  class TransportVehicleTestClass {\n    #wheels\n\n    constructor(wheels) {\n      this.#wheels = wheels\n    }\n\n    getWheels() {\n      return [...this.#wheels]\n    }\n\n    getObjectLiteral() {\n      return {\n        wheels: this.#wheels,\n      }\n    }\n  }\n\n  class AirportTestClass {\n    #transportVehicles\n    #airplanes\n\n    constructor(transportVehicles, airplanes) {\n      this.#transportVehicles = transportVehicles\n      this.#airplanes = airplanes\n    }\n\n    getTransportVehicles() {\n      return [...this.#transportVehicles]\n    }\n\n    getAirplanes() {\n      return [...this.#airplanes]\n    }\n\n    getObjectLiteral() {\n      return {\n        transportVehicles: this.#transportVehicles,\n        airplanes: this.#airplanes,\n      }\n    }\n  }\n\n  const transportVehicles = [\n    new TransportVehicleTestClass([\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n    ]),\n    new TransportVehicleTestClass([\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n    ]),\n    new TransportVehicleTestClass([\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n      new WheelTestClass(faker.number.int()),\n    ]),\n  ]\n\n  const airplanes = [\n    new AirplaneTestClass(faker.string.sample()),\n    new AirplaneTestClass(faker.string.sample()),\n    new AirplaneTestClass(faker.string.sample()),\n    new AirplaneTestClass(faker.string.sample()),\n    new AirplaneTestClass(faker.string.sample()),\n    new AirplaneTestClass(faker.string.sample()),\n    new AirplaneTestClass(faker.string.sample()),\n  ]\n\n  const unserializedData = new AirportTestClass(transportVehicles, airplanes)\n\n  const airportTestClassSerializer = getSerializer(\n    () =\u003e 'AirportTestClass',\n    (unserializerData) =\u003e ({\n      value: unserializerData.getObjectLiteral(),\n    }),\n    (serializedData) =\u003e {\n      const { value } = serializedData\n      const parameters = Object.values(value)\n      return new AirportTestClass(...parameters)\n    },\n  )\n\n  const airplaneTestClassSerializer = getSerializer(\n    () =\u003e 'AirplaneTestClass',\n    (unserializerData) =\u003e ({\n      value: unserializerData.getObjectLiteral(),\n    }),\n    (serializedData) =\u003e {\n      const { value } = serializedData\n      const parameters = Object.values(value)\n      return new AirplaneTestClass(...parameters)\n    },\n  )\n\n  const transportVehicleTestClassSerializer = getSerializer(\n    () =\u003e 'TransportVehicleTestClass',\n    (unserializerData) =\u003e ({\n      value: unserializerData.getObjectLiteral(),\n    }),\n    (serializedData) =\u003e {\n      const { value } = serializedData\n      const parameters = Object.values(value)\n      return new TransportVehicleTestClass(...parameters)\n    },\n  )\n\n  const wheelTestClassSerializer = getSerializer(\n    () =\u003e 'WheelTestClass',\n    (unserializerData) =\u003e ({\n      value: unserializerData.getObjectLiteral(),\n    }),\n    (serializedData) =\u003e {\n      const { value } = serializedData\n      const parameters = Object.values(value)\n      return new WheelTestClass(...parameters)\n    },\n  )\n\n  jsonSerializer.addSerializerAndRefreshJsonSerializer(\n    airportTestClassSerializer,\n  )\n  jsonSerializer.addSerializerAndRefreshJsonSerializer(\n    airplaneTestClassSerializer,\n  )\n  jsonSerializer.addSerializerAndRefreshJsonSerializer(\n    transportVehicleTestClassSerializer,\n  )\n  jsonSerializer.addSerializerAndRefreshJsonSerializer(wheelTestClassSerializer)\n\n  const serializedData = jsonSerializer.serialize(unserializedData)\n  ```\n\n  **For this case, the jsonSerializer.serialize(unserializedData) method returns the following JSON string**:\n\n  ```json\n  {\n    \"__typeof__\": \"AirportTestClass\",\n    \"value\": {\n      \"transportVehicles\": [\n        {\n          \"__typeof__\": \"TransportVehicleTestClass\",\n          \"value\": {\n            \"wheels\": [\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 1987494138609664 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 1819535013314560 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 6535380662747136 }\n              }\n            ]\n          }\n        },\n        {\n          \"__typeof__\": \"TransportVehicleTestClass\",\n          \"value\": {\n            \"wheels\": [\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 5250420016414720 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 7651029791277056 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 7619204396089344 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 8366722742484992 }\n              }\n            ]\n          }\n        },\n        {\n          \"__typeof__\": \"TransportVehicleTestClass\",\n          \"value\": {\n            \"wheels\": [\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 8390044339404800 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 6628758633054208 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 493054882480128 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 4292716229820416 }\n              },\n              {\n                \"__typeof__\": \"WheelTestClass\",\n                \"value\": { \"duration\": 5818243356819456 }\n              }\n            ]\n          }\n        }\n      ],\n      \"airplanes\": [\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"N\\\"X,(e+4zs\" }\n        },\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"WP)\u003c\\\"fn]vK\" }\n        },\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"b)D9bWv_;m\" }\n        },\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"`YQ4r|v9N(\" }\n        },\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"XN9r}G4ZWv\" }\n        },\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"]-u*,}_Ggp\" }\n        },\n        {\n          \"__typeof__\": \"AirplaneTestClass\",\n          \"value\": { \"model\": \"uY7o{p=Xt\u0026\" }\n        }\n      ]\n    }\n  }\n  ```\n\n  You can use the parse method to unserialize the serialized data.\n\n  ```js\n  const result = json.parse(serializedData)\n\n  /*\n     Returns all Airplanes\n     [\n      AirplaneTestClass {},\n      AirplaneTestClass {},\n      AirplaneTestClass {},\n      AirplaneTestClass {},\n      AirplaneTestClass {},\n      AirplaneTestClass {},\n      AirplaneTestClass {}\n    ]\n    */\n  console.log(result.getAirplanes())\n\n  /*\n     Returns all TransportVehicles\n     [                                                                                                                                              \n      TransportVehicleTestClass {},                                                                                                                \n      TransportVehicleTestClass {},                                                                                                                \n      TransportVehicleTestClass {}                                                                                                                 \n     ] \n    */\n  console.log(result.getTransportVehicles())\n  ```\n\n## \u003ca id=\"author\"\u003e\u003c/a\u003e Author\n\n👤 **Cristopher Jiménez**\n\n- Github: [@cristopher1](https://github.com/cristopher1)\n\n## \u003ca id=\"contributing\"\u003e\u003c/a\u003e 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/cristopher1/json-serializer/issues).\n\n## \u003ca id=\"license\"\u003e\u003c/a\u003e 📝 License\n\nCopyright © 2023 [Cristopher Jiménez](https://github.com/cristopher1).\u003cbr /\u003e\nThis project is [MIT](https://github.com/cristopher1/json-serializer/blob/master/LICENSE) licensed.\n\n---\n\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristopher1%2Fjson-serializer-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristopher1%2Fjson-serializer-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristopher1%2Fjson-serializer-core/lists"}