MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / isJSON

Function isJSON

apps/web/ui/Message/BlockCode/utilities.ts:9–20  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

7}
8
9function isJSON(code: string): boolean {
10 const input = code.trim();
11 if (!input.startsWith('{') || !input.endsWith('}')) {
12 return false;
13 }
14 try {
15 const output = JSON.parse(input);
16 return typeof output === 'object';
17 } catch (exception) {
18 return false;
19 }
20}
21
22export function formatCode(code: string): string {
23 if (isJSON(code)) {

Callers 2

isFormattableFunction · 0.85
formatCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected