read-json-safe
v4.0.0
Published
Read JSON files without try catch
Maintainers
Readme
Returns undefined on errors, for example if the file does not exist.
Installation
npm install read-json-safeyarn add read-json-safepnpm add read-json-safebun add read-json-safeUsage
Read a JSONValue:
import { readJSON, readJSONSync, JSONValue } from "read-json-safe";
readJSON("file.json"); // Promise<JSONValue | undefined>
readJSONSync("file.json"); // JSONValue | undefinedRead a JSONObject:
import { readJSONObject, readJSONObjectSync, JSONObject } from "read-json-safe";
readJSONObject("file.json"); // Promise<JSONObject | undefined>
readJSONObjectSync("file.json"); // JSONObject | undefinedRead a JSONArray:
import { readJSONArray, readJSONArraySync, JSONArray } from "read-json-safe";
readJSONArray("file.json"); // Promise<JSONArray | undefined>
readJSONArraySync("file.json"); // JSONArray | undefinedMIT - MIT License
Related Packages
- 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
