MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseJsonEntries

Function parseJsonEntries

src/tools/MCPTool/UI.tsx:266–291  ·  view source on GitHub ↗
(content: string, {
  maxChars,
  maxKeys
}: {
  maxChars: number;
  maxKeys: number;
})

Source from the content-addressed store, hash-verified

264 return `${k}: ${v}`;
265}
266function parseJsonEntries(content: string, {
267 maxChars,
268 maxKeys
269}: {
270 maxChars: number;
271 maxKeys: number;
272}): [string, unknown][] | null {
273 const trimmed = content.trim();
274 if (trimmed.length === 0 || trimmed.length > maxChars || trimmed[0] !== '{') {
275 return null;
276 }
277 let parsed: unknown;
278 try {
279 parsed = jsonParse(trimmed);
280 } catch {
281 return null;
282 }
283 if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
284 return null;
285 }
286 const entries = Object.entries(parsed);
287 if (entries.length === 0 || entries.length > maxKeys) {
288 return null;
289 }
290 return entries;
291}
292
293/**
294 * If content parses as a JSON object where every value is a scalar or a

Callers 3

tryFlattenJsonFunction · 0.85
tryUnwrapTextPayloadFunction · 0.85
trySlackSendCompactFunction · 0.85

Calls 2

jsonParseFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected