Socket
Socket
Sign inDemoInstall

json-stringify-safe

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-stringify-safe

Like JSON.stringify, but doesn't blow up on circular refs.


Version published
Weekly downloads
23M
increased by5.13%
Maintainers
2
Weekly downloads
 
Created

What is json-stringify-safe?

The json-stringify-safe package is a JSON serialization library that can stringify objects with circular references without throwing an error. It is particularly useful when dealing with complex objects where standard JSON.stringify() would fail due to circularity.

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

Stringify with circular references

This feature allows you to serialize objects that contain circular references by replacing the circular reference with a placeholder string that indicates the path of the circularity.

{"str": "Circular reference example", "obj": {"a": "b", "c": {"d": "[Circular ~.obj]"}}}

Custom replacer function

json-stringify-safe allows you to specify a custom replacer function to selectively serialize object properties, similar to the second argument of JSON.stringify().

{"str": "Custom replacer example", "obj": {"a": "b", "c": "[Filtered]"}}

Custom indentation

The package also supports custom indentation for the output string, allowing for more readable serialized JSON if needed.

{
  "str": "Indented output example",
  "obj": {
    "a": "b",
    "c": "d"
  }
}

Other packages similar to json-stringify-safe

Keywords

FAQs

Package last updated on 19 May 2015

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