Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

read-json-safe

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

read-json-safe

Read JSON files without try catch

latest
Source
npmnpm
Version
4.0.0
Version published
Weekly downloads
7.4K
14.51%
Maintainers
1
Weekly downloads
 
Created
Source

read-json-safe

NPM TypeScript Coverage Status

Read JSON files without try catch.

Returns undefined on errors, for example if the file does not exist.

Installation

NPM
npm install read-json-safe
Yarn
yarn add read-json-safe
PNPM
pnpm add read-json-safe
Bun
bun add read-json-safe

Usage

Read a JSONValue:

import { readJSON, readJSONSync, JSONValue } from "read-json-safe";

readJSON("file.json"); // Promise<JSONValue | undefined>
readJSONSync("file.json"); // JSONValue | undefined

Read a JSONObject:

import { readJSONObject, readJSONObjectSync, JSONObject } from "read-json-safe";

readJSONObject("file.json"); // Promise<JSONObject | undefined>
readJSONObjectSync("file.json"); // JSONObject | undefined

Read a JSONArray:

import { readJSONArray, readJSONArraySync, JSONArray } from "read-json-safe";

readJSONArray("file.json"); // Promise<JSONArray | undefined>
readJSONArraySync("file.json"); // JSONArray | undefined

License license

MIT - MIT License


  • fs-safe: A simple fs wrapper that doesn't throw
  • read-file-safe: Read files without try catch
  • read-lcov-safe: Read and parse an lcov file without try catch
  • read-md-safe: Read markdown files as a Marked token list or string

Keywords

json

FAQs

Package last updated on 11 Mar 2026

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