MCPcopy Create free account
hub / github.com/node-modules/utility / strictJSONParse

Function strictJSONParse

src/json.ts:5–11  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

3import { readFile, mkdir, writeFile } from 'node:fs/promises';
4
5export function strictJSONParse<T extends object = object>(content: string): T {
6 const obj = JSON.parse(content) as T;
7 if (!obj || typeof obj !== 'object') {
8 throw new Error('JSON string is not object');
9 }
10 return obj;
11}
12
13export function readJSONSync<T = any>(filepath: string): T {
14 return JSON.parse(readFileSync(filepath, 'utf8')) as T;

Callers 1

json.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…