Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-stable-stringify

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-stable-stringify

deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.9M
decreased by-20.58%
Maintainers
1
Weekly downloads
 
Created

What is json-stable-stringify?

The json-stable-stringify npm package is used to convert a JavaScript object into a JSON string with a deterministic order of keys. This is particularly useful when you want to ensure that the string output is consistent for the same structural data, which is important for tasks like creating cryptographic hashes, caching, or simply when you need a stable serialization of JSON that you can compare.

What are json-stable-stringify's main functionalities?

Deterministic JSON.stringify

This feature allows you to serialize a JavaScript object into a JSON string with a consistent ordering of keys. This is useful when you need to compare JSON strings for equality or when you need to generate a hash from a JSON string and require that the string be the same for the same data.

{"result": "json-stable-stringify"}

Custom comparator

json-stable-stringify allows you to provide a custom comparison function to determine the order of keys. This is useful when you have specific requirements for the order of keys beyond simple alphabetical sorting.

{"result": "json-stable-stringify with custom comparator"}

Space argument for pretty-printing

The package also supports the 'space' argument like JSON.stringify, which allows you to pretty-print the output with indentation for better readability.

{"result": "json-stable-stringify with pretty-printing"}

Other packages similar to json-stable-stringify

Keywords

FAQs

Package last updated on 16 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc