MCPcopy Index your code
hub / github.com/simstudioai/sim / parseJSONLContent

Function parseJSONLContent

apps/sim/lib/file-parsers/json-parser.ts:80–104  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

78}
79
80function parseJSONLContent(content: string): FileParseResult {
81 const lines = content.split('\n').filter((line) => line.trim())
82 const items: unknown[] = []
83
84 for (const line of lines) {
85 try {
86 items.push(JSON.parse(line))
87 } catch {
88 throw new Error(`Invalid JSONL: failed to parse line: ${line.slice(0, 100)}`)
89 }
90 }
91
92 const formattedContent = JSON.stringify(items, null, 2)
93
94 return {
95 content: formattedContent,
96 metadata: {
97 type: 'json',
98 isArray: true,
99 keys: [],
100 itemCount: items.length,
101 depth: items.length > 0 ? 1 + getJsonDepth(items[0]) : 1,
102 },
103 }
104}
105
106/**
107 * Calculate the depth of a JSON object

Callers 2

parseJSONLFunction · 0.85
parseJSONLBufferFunction · 0.85

Calls 3

getJsonDepthFunction · 0.85
parseMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected