MCPcopy
hub / github.com/TanStack/ai / parse

Method parse

packages/ai/src/activities/chat/stream/json-parser.ts:31–43  ·  view source on GitHub ↗

* Parse a potentially incomplete JSON string * @param jsonString - The JSON string to parse (may be incomplete) * @returns The parsed object, or undefined if parsing fails

(jsonString: string)

Source from the content-addressed store, hash-verified

29 * @returns The parsed object, or undefined if parsing fails
30 */
31 parse(jsonString: string): any {
32 if (!jsonString || jsonString.trim() === '') {
33 return undefined
34 }
35
36 try {
37 return parsePartialJSONLib(jsonString)
38 } catch {
39 // If partial parsing fails, return undefined
40 // This is expected during early streaming when we have very little data
41 return undefined
42 }
43 }
44}
45
46/**

Callers 15

safeJsonParseFunction · 0.80
loadGoldFileFunction · 0.80
readRunLogFunction · 0.80
structuredOutputFunction · 0.80
structuredOutputStreamFunction · 0.80
processStreamChunksFunction · 0.80
structuredOutputFunction · 0.80
structuredOutputStreamFunction · 0.80
processStreamChunksFunction · 0.80
parseToolCallInputFunction · 0.80

Calls

no outgoing calls

Tested by 15

installFetchFunction · 0.64
parseSSEStreamFunction · 0.64
readFetchCallFunction · 0.64
captureSerializedToolFunction · 0.64
captureSerializedToolsFunction · 0.64
provisionFunction · 0.64
parseStringArrayFunction · 0.64
parseChunkSummariesFunction · 0.64
runLifecycleFunction · 0.64
parseSseFunction · 0.64
parseSseFunction · 0.64
parseSseFunction · 0.64