ion7-llm / util.partial_json

module

util.partial_json

Functions

M.new

New buffer.

M.new()
→ ion7.llm.util.PartialJsonBuffer

Buffer:append

Feed a fragment. The internal balance counter is updated in O(n).

Buffer:append(s)
sstring
→ ion7.llm.util.PartialJsonBufferself (chainable)

Buffer:string

Raw accumulated string. Useful when the caller wants to parse with their own JSON library, or to stash the buffer for replay.

Buffer:string()
→ string

Buffer:complete

True when the buffer contains a balanced JSON value (object or array) AND we are not currently inside a string. For primitive top-level values (number / bool / null) the buffer is considered complete as soon as `_started` is true and not inside a string.

Buffer:complete()
→ boolean

Buffer:reset

Clear the buffer.

Buffer:reset()

Buffer:value

Parse the buffer to a Lua value. Returns `(value, nil)` on success or `(nil, err)` on parse failure. Calling `:value()` on an incomplete buffer returns `(nil, "incomplete")`.

Buffer:value()
→ any|nil
→ string?