Read JSON files without try catch
npm install read-json-safeRead 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.
``sh`
yarn add read-json-safe
`sh`
npm install read-json-safe
`sh`
pnpm add read-json-safe
`ts
import { readJSON, readJSONSync, JSONValue } from "read-json-safe";
readJSON("file.json"); // Promise
readJSONSync("file.json"); // JSONValue | undefined
`
`ts
import { readJSONObject, readJSONObjectSync, JSONObject } from "read-json-safe";
readJSONObject("file.json"); // Promise
readJSONObjectSync("file.json"); // JSONObject | undefined
`
`ts
import { readJSONArray, readJSONArraySync, JSONArray } from "read-json-safe";
readJSONArray("file.json"); // Promise
readJSONArraySync("file.json"); // JSONArray | undefined
``
- parse-json-object: Parse a typed JSON object
- read-file-safe: Read files without try catch
- @types/mock-fs: TypeScript definitions for mock-fs
- @types/node: TypeScript definitions for Node.js
- autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.
- mock-fs: A configurable mock file system. You know, for testing.
- 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