llm
streaming
ai_generated
true
JSON parse error during streaming — incomplete JSON in stream chunk
ID: llm/streaming-json-partial-parse-error
90%Fix Rate
92%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Parsing JSON from streamed LLM output fails because chunks contain incomplete JSON.
genericWorkarounds
-
93% success Accumulate stream chunks into a buffer and parse only when complete
buffer += chunk; try: result = json.loads(buffer) except: continue
Sources: https://platform.openai.com/docs/api-reference/streaming
-
88% success Use a streaming JSON parser that handles partial input
Use libraries like partial-json-parser or ijson
Dead Ends
Common approaches that don't work:
-
JSON.parse each chunk individually
95% fail
Stream chunks are arbitrary byte boundaries, not JSON boundaries
-
Wait for a closing brace to trigger parsing
75% fail
Nested objects have multiple closing braces; triggering on first } gives incomplete parse