{"id":26798044,"url":"https://github.com/ftwinston/enhancejson","last_synced_at":"2025-04-22T22:10:57.843Z","repository":{"id":57238368,"uuid":"370964836","full_name":"FTWinston/enhanceJSON","owner":"FTWinston","description":"Parse/stringify object trees to JSON, with support for Map, Set and Date","archived":false,"fork":false,"pushed_at":"2024-04-09T21:31:57.000Z","size":210,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T05:21:12.454Z","etag":null,"topics":["deserialization","json","serialization"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/FTWinston.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-05-26T08:40:42.000Z","updated_at":"2024-08-01T01:15:09.000Z","dependencies_parsed_at":"2024-04-01T14:25:44.429Z","dependency_job_id":"8e06cf28-822e-48bc-adc1-bfe35bf5dbdf","html_url":"https://github.com/FTWinston/enhanceJSON","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FTWinston%2FenhanceJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FTWinston%2FenhanceJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FTWinston%2FenhanceJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FTWinston%2FenhanceJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FTWinston","download_url":"https://codeload.github.com/FTWinston/enhanceJSON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246230506,"owners_count":20744349,"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":["deserialization","json","serialization"],"created_at":"2025-03-29T19:16:44.080Z","updated_at":"2025-03-29T19:16:44.575Z","avatar_url":"https://github.com/FTWinston.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# enhanceJSON\nStringify/parse object trees to/from JSON, with support for Map, Set and Date.\n\nenhanceJSON offers drop-in replacements for JSON.parse and JSON.stringify, with identical signatures to those methods.\n\n![Version badge](https://badgen.net/npm/v/enhancejson) ![Minified badge](https://badgen.net/bundlephobia/min/enhancejson) ![Minzipped badge](https://badgen.net/bundlephobia/minzip/enhancejson) ![Dependencies badge](https://badgen.net/bundlephobia/dependency-count/enhancejson) ![Types badge](https://badgen.net/npm/types/enhancejson) [![NodeJS CI](https://github.com/FTWinston/enhancejson/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/FTWinston/enhancejson/actions/workflows/test.yml)\n\n## Installation\nRun `npm install --save enhancejson`\n\n## Usage\nenhanceJSON is used in the same way as you'd call `JSON.stringify` / `JSON.parse`.\n\nInternally, it uses a custom replacer and reviver to handle `Map`, `Set` and `Date` values. Objects representing these types are identified by means of a `__type` field, which is added automatically. You should avoid using this key in your own data. Alternatively, you can specify a different key to use via the `typeKey`  parameter on each method.\n\nYou can specify your own replacer and/or reviver, which will be used before (for replacers) or after (for revivers) the internal ones, when calling `stringify` or `parse`.\n\n```javascript\nimport * as enhanceJSON from 'enhancejson';\n\nconst data = {\n  val1: 'test',\n  map: new Map([[1, 'one'], [2, 'two']]),\n  child: {\n    sets: [\n      new Set([1, 2, 3]),\n      new Set(['a', 'b', 'c']),\n    ],\n    date: new Date('2024-04-06'),\n  }\n}\n\nconst strData = enhanceJSON.stringify(data);\nconst newData = enhanceJSON.parse(strData);\n\nexpect(newData).toEqual(data);\n\nexpect(typeof strData).toEqual('string');\nexpect(strData).toEqual(`{\"val1\":\"test\",\"map\":{\"__type\":\"M\",\"v\":[[1,\"one\"],[2,\"two\"]]},\"child\":{\"sets\":[{\"__type\":\"S\",\"v\":[1,2,3]},{\"__type\":\"S\",\"v\":[\"a\",\"b\",\"c\"]}],\"date\":{\"__type\":\"D\",\"v\":\"2024-04-06T00:00:00.000Z\"}}}`);\n```\n\n## JSON format\nWhen the `stringify` function finds a `Map`, `Set` or `Date` value, it will output an object with a `__type` key of `\"M\"`, `\"S\"` or `\"D\"`, respectively. Another field on this same object will contain an array (for `Map` and `Set`) or string (for `Date`) representation of the original object.\n\nWhen the `parse` function finds an object with this key, it assumes that it represents the corresponding data type, and will revive it as such.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fftwinston%2Fenhancejson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fftwinston%2Fenhancejson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fftwinston%2Fenhancejson/lists"}