Documentation
¶
Overview ¶
Package partialjson parses the incomplete JSON emitted while tool-call arguments are streaming.
Index ¶
- Constants
- func Parse(input string, allowed ...Allow) (any, error)
- func ParseJSONWithRepair(input string) (any, error)
- func ParseStreamingJSON(input string) any
- func RepairJSON(input string) string
- func StringifyStreamingJSON(input string) ([]byte, error)
- type Allow
- type MalformedJSONError
- type PartialJSONError
Constants ¶
const ( AllowString Allow = 1 << iota AllowNumber AllowArray AllowObject AllowNull AllowBool AllowNaN AllowInfinity AllowNegativeInfinity AllowInf = AllowInfinity | AllowNegativeInfinity AllowSpecial = AllowNull | AllowBool | AllowInf | AllowNaN AllowAtom = AllowString | AllowNumber | AllowSpecial AllowCollection = AllowArray | AllowObject AllowAll = AllowAtom | AllowCollection )
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses incomplete JSON. With no allow mask it permits every partial value, matching partial-json 0.1.7's default.
func ParseJSONWithRepair ¶
ParseJSONWithRepair first parses strict JSON, then retries after RepairJSON.
func ParseStreamingJSON ¶
ParseStreamingJSON parses tool-call arguments as they arrive. It never returns an error; invalid, empty, and incomplete-null input becomes {}.
func RepairJSON ¶
RepairJSON escapes raw control characters and invalid backslash escapes inside JSON strings. It intentionally leaves structure untouched.
func StringifyStreamingJSON ¶
StringifyStreamingJSON parses an incomplete value and serializes the currently available result with JSON.parse/JSON.stringify property order.
Types ¶
type MalformedJSONError ¶
MalformedJSONError reports input that cannot be parsed as JSON, partial or complete.
func (*MalformedJSONError) Error ¶
func (e *MalformedJSONError) Error() string
type PartialJSONError ¶
PartialJSONError reports an incomplete value disallowed by Parse's mask.
func (*PartialJSONError) Error ¶
func (e *PartialJSONError) Error() string