MCPcopy
hub / github.com/claude-code-best/claude-code / safeParseJSONC

Function safeParseJSONC

src/utils/json.ts:65–76  ·  view source on GitHub ↗
(json: string | null | undefined)

Source from the content-addressed store, hash-verified

63 * which support comments and other jsonc features.
64 */
65export function safeParseJSONC(json: string | null | undefined): unknown {
66 if (!json) {
67 return null
68 }
69 try {
70 // Strip BOM before parsing - PowerShell 5.x adds BOM to UTF-8 files
71 return parseJsonc(stripBOM(json))
72 } catch (e) {
73 logError(e)
74 return null
75 }
76}
77
78/**
79 * Modify a jsonc string by adding a new item to an array, preserving comments and formatting.

Callers 2

json.test.tsFile · 0.85

Calls 2

stripBOMFunction · 0.90
logErrorFunction · 0.70

Tested by

no test coverage detected