MCPcopy
hub / github.com/loggerhead/json4u / prettyFormatWithFallback

Function prettyFormatWithFallback

src/lib/format/pretty.ts:39–42  ·  view source on GitHub ↗
(json: string, options?: ParseOptions)

Source from the content-addressed store, hash-verified

37}
38
39function prettyFormatWithFallback(json: string, options?: ParseOptions): string {
40 const tree = parseJSON(json);
41 return tree.valid() ? tree.stringify({ format: true }) : textFormat(json, options);
42}
43
44/**
45 * Finds all top-level, valid JSON objects or arrays within a string.

Callers 1

prettyFormatFunction · 0.85

Calls 4

parseJSONFunction · 0.90
textFormatFunction · 0.90
validMethod · 0.80
stringifyMethod · 0.80

Tested by

no test coverage detected