$ gnpm install read-json-safe
Read JSON files without try catch.
If I should maintain this repo, please ⭐️
DM me on Twitter if you have questions or suggestions.
Returns undefined
on errors, for example if the file does not exist.
yarn add read-json-safe
npm install read-json-safe
pnpm add read-json-safe
import { readJSON, readJSONSync, JSONValue } from "read-json-safe";
readJSON("file.json"); // Promise<JSONValue | undefined>
readJSONSync("file.json"); // JSONValue | undefined
import { readJSONObject, readJSONObjectSync, JSONObject } from "read-json-safe";
readJSONObject("file.json"); // Promise<JSONObject | undefined>
readJSONObjectSync("file.json"); // JSONObject | undefined
import { readJSONArray, readJSONArraySync, JSONArray } from "read-json-safe";
readJSONArray("file.json"); // Promise<JSONArray | undefined>
readJSONArraySync("file.json"); // JSONArray | undefined
Copyright 2013 - present © cnpmjs.org | Home |