🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

destr

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

destr

A faster, secure and convenient alternative for JSON.parse

2.0.5
latest
Source
npm
Version published
Weekly downloads
4M
0.4%
Maintainers
1
Weekly downloads
 
Created

What is destr?

The `destr` npm package is designed to safely parse JSON strings without throwing an error for invalid JSON. It can return the original string if parsing fails, making it useful for handling dynamic JSON data that may not always be properly formatted. It also recognizes and correctly parses values like `null`, `true`, `false`, and `undefined`.

What are destr's main functionalities?

Safe JSON parsing

Safely parse a JSON string without throwing an error. If the string is not valid JSON, it returns the original string.

"const destr = require('destr');
const json = '{\"key\":\"value\"}';
const parsed = destr(json);
console.log(parsed); // Output: { key: 'value' }"

Parsing special JSON values

Correctly parse special JSON values such as `null`, `true`, `false`, and `undefined`, returning their corresponding JavaScript types.

"const destr = require('destr');
console.log(destr('null')); // Output: null
console.log(destr('true')); // Output: true
console.log(destr('false')); // Output: false
console.log(destr('undefined')); // Output: undefined"

Other packages similar to destr

FAQs

Package last updated on 03 Apr 2025

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