Skip to main content

Module json_parse

Module json_parse 

Source
Expand description

Lenient JSON parsing for model output: tool-call arguments and server-sent event payloads.

Functions§

js_parse_error
The message of the error JavaScript’s JSON.parse throws for text, as V8 words it, or None when text is valid JSON.
parse_json_with_repair
Parses JSON, retrying once on the repair_json form.
parse_streaming_json
Parses possibly incomplete tool-call arguments into an object.
repair_json
Escapes what models commonly emit raw inside JSON strings: control characters, lone backslashes and invalid escapes. Valid JSON is returned unchanged.