MCPcopy Create free account
hub / github.com/getagentseal/codeburn / readJsonString

Function readJsonString

src/parser.ts:242–268  ·  view source on GitHub ↗
(source: string, bounds: JsonValueBounds | null, cap = Number.POSITIVE_INFINITY)

Source from the content-addressed store, hash-verified

240}
241
242function readJsonString(source: string, bounds: JsonValueBounds | null, cap = Number.POSITIVE_INFINITY): string | undefined {
243 if (!bounds || bounds.kind !== 'string') return undefined
244 let out = ''
245 for (let i = bounds.start + 1; i < bounds.end - 1 && out.length < cap; i++) {
246 const ch = source[i]!
247 if (ch !== '\\') {
248 out += ch
249 continue
250 }
251 const next = source[++i]
252 if (!next) break
253 if (next === 'n') out += '\n'
254 else if (next === 'r') out += '\r'
255 else if (next === 't') out += '\t'
256 else if (next === 'b') out += '\b'
257 else if (next === 'f') out += '\f'
258 else if (next === 'u' && i + 4 < bounds.end) {
259 const hex = source.slice(i + 1, i + 5)
260 const code = Number.parseInt(hex, 16)
261 if (Number.isFinite(code)) out += String.fromCharCode(code)
262 i += 4
263 } else {
264 out += next
265 }
266 }
267 return out
268}
269
270function readJsonNumberField(source: string, objectBounds: JsonValueBounds | null, field: string): number | undefined {
271 if (!objectBounds || objectBounds.kind !== 'object') return undefined

Callers 6

parseLargeUsageFunction · 0.85
extractLargeToolBlocksFunction · 0.85
extractLargeUserTextFunction · 0.85
extractLargeAddedNamesFunction · 0.85
parseLargeJsonlLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected