{"id":13524899,"url":"https://github.com/epoberezkin/fast-json-stable-stringify","last_synced_at":"2025-04-01T03:32:53.242Z","repository":{"id":26325902,"uuid":"108103016","full_name":"epoberezkin/fast-json-stable-stringify","owner":"epoberezkin","description":"Deterministic JSON.stringify() - a faster version of @substack's json-stable-strigify without jsonify.","archived":false,"fork":true,"pushed_at":"2023-07-03T08:14:47.000Z","size":93,"stargazers_count":299,"open_issues_count":21,"forks_count":34,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-19T23:02:40.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"carlos8f/json-stable-stringify","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epoberezkin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"epoberezkin","tidelift":"npm/fast-json-stable-stringify"}},"created_at":"2017-10-24T09:07:57.000Z","updated_at":"2025-03-13T11:40:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/epoberezkin/fast-json-stable-stringify","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoberezkin%2Ffast-json-stable-stringify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoberezkin%2Ffast-json-stable-stringify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoberezkin%2Ffast-json-stable-stringify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoberezkin%2Ffast-json-stable-stringify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epoberezkin","download_url":"https://codeload.github.com/epoberezkin/fast-json-stable-stringify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244682934,"owners_count":20493088,"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":[],"created_at":"2024-08-01T06:01:14.390Z","updated_at":"2025-04-01T03:32:52.997Z","avatar_url":"https://github.com/epoberezkin.png","language":"JavaScript","funding_links":["https://github.com/sponsors/epoberezkin","https://tidelift.com/funding/github/npm/fast-json-stable-stringify","https://tidelift.com/subscription/pkg/npm-fast-json-stable-stringify?utm_source=npm-fast-json-stable-stringify\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo","https://tidelift.com/security"],"categories":["JavaScript","Repository"],"sub_categories":["Object / JSON / JSON Schema"],"readme":"# fast-json-stable-stringify\n\nDeterministic `JSON.stringify()` - a faster version of [@substack](https://github.com/substack)'s json-stable-strigify without [jsonify](https://github.com/substack/jsonify).\n\nYou can also pass in a custom comparison function.\n\n[![Build Status](https://travis-ci.org/epoberezkin/fast-json-stable-stringify.svg?branch=master)](https://travis-ci.org/epoberezkin/fast-json-stable-stringify)\n[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/fast-json-stable-stringify/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/fast-json-stable-stringify?branch=master)\n\n# example\n\n``` js\nvar stringify = require('fast-json-stable-stringify');\nvar obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };\nconsole.log(stringify(obj));\n```\n\noutput:\n\n```\n{\"a\":3,\"b\":[{\"x\":4,\"y\":5,\"z\":6},7],\"c\":8}\n```\n\n\n# methods\n\n``` js\nvar stringify = require('fast-json-stable-stringify')\n```\n\n## var str = stringify(obj, opts)\n\nReturn a deterministic stringified string `str` from the object `obj`.\n\n\n## options\n\n### cmp\n\nIf `opts` is given, you can supply an `opts.cmp` to have a custom comparison\nfunction for object keys. Your function `opts.cmp` is called with these\nparameters:\n\n``` js\nopts.cmp({ key: akey, value: avalue }, { key: bkey, value: bvalue })\n```\n\nFor example, to sort on the object key names in reverse order you could write:\n\n``` js\nvar stringify = require('fast-json-stable-stringify');\n\nvar obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };\nvar s = stringify(obj, function (a, b) {\n    return a.key \u003c b.key ? 1 : -1;\n});\nconsole.log(s);\n```\n\nwhich results in the output string:\n\n```\n{\"c\":8,\"b\":[{\"z\":6,\"y\":5,\"x\":4},7],\"a\":3}\n```\n\nOr if you wanted to sort on the object values in reverse order, you could write:\n\n```\nvar stringify = require('fast-json-stable-stringify');\n\nvar obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 };\nvar s = stringify(obj, function (a, b) {\n    return a.value \u003c b.value ? 1 : -1;\n});\nconsole.log(s);\n```\n\nwhich outputs:\n\n```\n{\"d\":6,\"c\":5,\"b\":[{\"z\":3,\"y\":2,\"x\":1},9],\"a\":10}\n```\n\n### cycles\n\nPass `true` in `opts.cycles` to stringify circular property as `__cycle__` - the result will not be a valid JSON string in this case.\n\nTypeError will be thrown in case of circular object without this option.\n\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install fast-json-stable-stringify\n```\n\n\n# benchmark\n\nTo run benchmark (requires Node.js 6+):\n```\nnode benchmark\n```\n\nResults:\n```\nfast-json-stable-stringify x 17,189 ops/sec ±1.43% (83 runs sampled)\njson-stable-stringify x 13,634 ops/sec ±1.39% (85 runs sampled)\nfast-stable-stringify x 20,212 ops/sec ±1.20% (84 runs sampled)\nfaster-stable-stringify x 15,549 ops/sec ±1.12% (84 runs sampled)\nThe fastest is fast-stable-stringify\n```\n\n\n## Enterprise support\n\nfast-json-stable-stringify package is a part of [Tidelift enterprise subscription](https://tidelift.com/subscription/pkg/npm-fast-json-stable-stringify?utm_source=npm-fast-json-stable-stringify\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo) - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.\n\n\n## Security contact\n\nTo report a security vulnerability, please use the\n[Tidelift security contact](https://tidelift.com/security).\nTidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.\n\n\n# license\n\n[MIT](https://github.com/epoberezkin/fast-json-stable-stringify/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepoberezkin%2Ffast-json-stable-stringify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepoberezkin%2Ffast-json-stable-stringify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepoberezkin%2Ffast-json-stable-stringify/lists"}