StreamingJSON is a Python library designed to preprocess incomplete JSON strings, transforming them into valid, parseable JSON in real-time. This addresses challenges in stream JSON parsing, especially relevant for Large Language Models (LLMs), by enabling immediate data processing without waiting for full JSON generation. It works by completing fragmented JSON, allowing other standard JSON libraries to parse its output seamlessly. The library is currently in an active development phase, with version 0.0.5 being the latest release, and follows a rapid release cadence.
pip install streamingjsonVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize the `Lexer`, append string segments incrementally, and retrieve the completed (syntactically valid) JSON at any point in the stream. It highlights the use of a new `Lexer` instance per stream and the library's ability to handle various JSON fragments and escaped characters.
Always instantiate `streamingjson.Lexer()` for each new independent JSON stream you intend to process.
Understand that `Lexer.complete_json()` provides a *string* representation of valid JSON. Use `json.loads(lexer.complete_json())` for object deserialization.
Pin your dependency to an exact version (e.g., `streamingjson==0.0.5`) in `requirements.txt` to avoid unexpected breakage from updates. Review changelogs carefully when upgrading.
Ensure you are using `streamingjson` version `0.0.5` or later to benefit from critical bug fixes related to string parsing. Report any unexpected parsing behavior for complex string content.
No dependency data recorded yet.
No resource links recorded.