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

Function findObjectFieldValue

src/parser.ts:215–240  ·  view source on GitHub ↗
(source: string, objectStart: number, objectEnd: number, field: string)

Source from the content-addressed store, hash-verified

213}
214
215function findObjectFieldValue(source: string, objectStart: number, objectEnd: number, field: string): JsonValueBounds | null {
216 if (source.charCodeAt(objectStart) !== 0x7b) return null
217 let i = objectStart + 1
218 while (i < objectEnd - 1) {
219 while (i < objectEnd && /\s/.test(source[i]!)) i++
220 if (source.charCodeAt(i) === 0x2c) {
221 i++
222 continue
223 }
224 if (source.charCodeAt(i) !== 0x22) {
225 i++
226 continue
227 }
228 const keyEnd = findJsonStringEnd(source, i, objectEnd)
229 if (keyEnd === -1) return null
230 const key = source.slice(i + 1, keyEnd)
231 i = keyEnd + 1
232 while (i < objectEnd && /\s/.test(source[i]!)) i++
233 if (source.charCodeAt(i) !== 0x3a) continue
234 const value = findJsonValueBounds(source, i + 1, objectEnd)
235 if (!value) return null
236 if (key === field) return value
237 i = value.end
238 }
239 return null
240}
241
242function readJsonString(source: string, bounds: JsonValueBounds | null, cap = Number.POSITIVE_INFINITY): string | undefined {
243 if (!bounds || bounds.kind !== 'string') return undefined

Callers 6

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

Calls 2

findJsonStringEndFunction · 0.85
findJsonValueBoundsFunction · 0.85

Tested by

no test coverage detected