Expand description
Repair and parse truncated JSON.
Streaming models emit JSON text incrementally. repair closes open
strings, arrays and objects, completes partial literals (tru → true)
and drops trailing separators so that any prefix of a valid document
becomes parseable. parse_partial tries a direct parse first and falls
back to repair.
Derived from the fixJson state machine of the Vercel AI SDK (Apache-2.0,
Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and
modified; see NOTICE.
Structs§
- Partial
Parse - Outcome of
parse_partial.
Enums§
- Partial
Parse State - How a partial parse succeeded or failed.
Functions§
- parse_
optional - Parses optional JSON text, distinguishing absent input from invalid JSON.
- parse_
partial - Parses
text, repairing it first if a direct parse fails. - repair
- Repairs truncated JSON so that it parses.