{"id":17749543,"url":"https://github.com/oresoftware/safe-stringify","last_synced_at":"2025-12-30T23:13:42.187Z","repository":{"id":95713151,"uuid":"144808872","full_name":"ORESoftware/safe-stringify","owner":"ORESoftware","description":"Handles circular objects/references for JS to JSON serialization.","archived":false,"fork":false,"pushed_at":"2019-10-01T01:06:51.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-02T00:26:08.637Z","etag":null,"topics":["javascript","javascript-library","json","json-api","json-server","nodejs","npm","npm-package"],"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/ORESoftware.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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-15T05:16:21.000Z","updated_at":"2020-09-27T14:05:21.000Z","dependencies_parsed_at":"2023-05-21T17:45:15.751Z","dependency_job_id":null,"html_url":"https://github.com/ORESoftware/safe-stringify","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsafe-stringify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsafe-stringify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsafe-stringify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsafe-stringify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ORESoftware","download_url":"https://codeload.github.com/ORESoftware/safe-stringify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246604611,"owners_count":20804100,"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":["javascript","javascript-library","json","json-api","json-server","nodejs","npm","npm-package"],"created_at":"2024-10-26T11:23:42.716Z","updated_at":"2025-12-30T23:13:42.155Z","avatar_url":"https://github.com/ORESoftware.png","language":"TypeScript","readme":"\n[![Version](https://img.shields.io/npm/v/@oresoftware/safe-stringify.svg?colorB=green)](https://www.npmjs.com/package/@oresoftware/safe-stringify)\n\n# @oresoftware/safe-stringify\n\n\n####  Motivation/purpose for this library:\n\n\u003e [See this Github gist](https://gist.github.com/ORESoftware/10bd74e27728a2aa764df4d6c6ecada8) \n\n\n###  Installation:\n\n\u003e\n\u003e```bash\n\u003e $ npm i -S '@oresoftware/safe-stringify'\n\u003e```\n\u003e\n\n##  For most objects (this is more performant)\n\n```js\nimport * as safe from '@oresoftware/safe-stringify';\nconst s = safe.stringify({});\n```\n\n##  For use with more complex deeply-nested objects with arrays:\n\n\nNote: stringifyDeep is *not* production ready, please don't use it yet, \nwithout improving it and making sure it works for you.\n\n\n```js\nimport * as safe from '@oresoftware/safe-stringify';\nconst s = safe.stringifyDeep([{}]);\n```\n\nFor example the following works with `stringifyDeep` but not `stringify`:\n\n```js\nconst x = {dog:'bark'};\nx.mmm = {'zebra': 3};\nx.mmm = x;\n\nconst v = [x,x,x];\nv.zzz = v;\nv.foo = 5;\nv.dog = 3;\n\nconst mmm = safe.stringifyDeep([v,v,v]);\nconsole.log(mmm);\n\n```\n\n\n## \u003e Using Map and Set, etc\n\nThis library does not treat Map and Set or other classes as special. To serialize a Map or Set instance, \nyou might do:\n\n```js\n\nclass HasMapAndSet {\n  \n  constructor(){\n    this.map = new Map([['one',1], ['two',2]]);\n    this.set = new Set([1,2,3]);\n  }\n   \n  toJSON(){  // use this to transform Map and Set to {} or []\n    return {\n      map: Array.from(this.map),\n      set: Array.from(this.set)\n    }\n  }\n  \n}\n\n\nconsole.log(\n  JSON.stringify(\n    new HasMapAndSet()\n  )\n);\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foresoftware%2Fsafe-stringify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foresoftware%2Fsafe-stringify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foresoftware%2Fsafe-stringify/lists"}