Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 3, 2024 via pnpm

json-stable-stringify 1.0.2

deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results
Package summary
Share
2
issues
1
high severity
license
1
1
low severity
license
1
2
licenses
1
MIT
1
Public Domain
Package created
17 Jul 2013
Version published
8 Nov 2022
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

2

1 high severity issue

high
Recommendation: Validate that the package complies with your license policy
via: jsonify@0.0.1
Collapse
Expand

1 low severity issue

low
Recommendation: Read and validate the license terms
via: jsonify@0.0.1
Collapse
Expand

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
json-stable-stringify@1.0.2

Public Domain

Invalid
Not OSI Approved
1 Packages, Including:
jsonify@0.0.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
ⓘ This is a list of json-stable-stringify 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
jsonify0.0.17.27 kBPublic Domain
prod
1
1

Visualizations

Frequently Asked Questions

What does json-stable-stringify do?

The npm package json-stable-stringify is designed to offer a deterministic version of JSON.stringify(). It allows users to get consistent hashes from stringified results. This tool is ideal for times you need predictability in your JSON strings, ensuring that they are consistently structured and will always produce the same output when given the same input.

How do you use json-stable-stringify?

Using json-stable-stringify is straightforward. You first need to install it via npm with the command npm install json-stable-stringify. Once installed, you can require it in your JavaScript code as follows:

var stringify = require('json-stable-stringify');
var obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 };
console.log(stringify(obj));
// Outputs: {"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}

You can pass in custom comparison functions to sort the keys according to your need:

var s = stringify(obj, function (a, b) {
	return b.key.localeCompare(a.key);
});
console.log(s);
// Outputs: {"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3}

In addition, prettifying your stringified output is also feasible by specifying the space in the options:

var s = stringify(obj, { space: '  ' });
console.log(s);
// Outputs:
// {
//   "a": {
//     "and": [
//       1,
//       2,
//       3
//     ],
//     "foo": "bar"
//   },
//   "b": 1
// }

Where are the json-stable-stringify docs?

The detailed documentation and instructions for json-stable-stringify can be found on its GitHub page: https://github.com/ljharb/json-stable-stringify. This README.md file includes all the necessary guidelines, from installation to options and methods you can employ to customize the function’s behavior, such as the comparison function, replacer, and space.